Git Product home page Git Product logo

Comments (6)

Geequlim avatar Geequlim commented on August 12, 2024 1

Thanks for your report.
This bug will be fixed in next release.

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024 1

The latest commit fixed this problem.
Here is the demo to using anonymous ECMAScript with the gdclass decorator in TypeScript.

import { signal, gdclass, property } from "./decorators";

@gdclass
class MyNode extends godot.Control {
	@signal
	test_func: string;
	
	js_method_test() {}

	@property({ default: "Hello Godot Property" })
	string_prop: string;
}

@gdclass
class MyMyNode extends MyNode {
	@signal
	test_func2: string;
};

export default class Control extends godot.Control {

	_ready() {
		console.log('--------------');
		var n = new MyMyNode();
		console.log(n.has_signal('test_func'));
		console.log(n.has_signal('test_func2'));
		console.log(n.string_prop === 'Hello Godot Property');
		console.log(n.has_method('js_method_test'));
		n.free();
		console.log('--------------');
	}

}

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

honestly I'm not sure what the behavior in gdscript is, although I believe the behavior I'm expecting did work in C#. I should check in gdscript.

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

I was able to get around this for now like so:

import B from "./B.jsx"
export default class A extends godot.Node {
  @signal static readonly mysignal: string;
  _ready() {
    const b = new B();
    b.set_script(godot.load('res://B.jsx')
    this.add_child(b);
  }
}

You can't preload or there will be a stack overflow because of a cyclic dependency it seems.

from ecmascript.

MichaelBelousov avatar MichaelBelousov commented on August 12, 2024

@Geequlim I am starting to use the gdclass decorator and it's not in the generated decorators.js, it's in the godot.d.ts, is this intended? I had to manually move it over for it work since .d.ts files don't emit js.

from ecmascript.

Geequlim avatar Geequlim commented on August 12, 2024

@MichaelBelousov Thanks for your remind. gdclass is moved to decorator.ts now.

from ecmascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.