When I was looking into type generation error of GDScript, I found more issues and have some thoughts on how to improve:
Static methods and properties are not included.
I can help adding static methods and properties to the type generation code. But I noticed the current way of using GDScript in Javascript is not very ergonomic. While generated types help writing code, readability still suffers.
I suggest we can have a function which creates Proxy objects that wrap around GDScript classes, so we can use them in a more natural way. So that instead of gdscript.call("method", parameter), we can write gdscript.method(parameter).
godotTsMap is not complete.
Resulting in things like RefCounted and Node3D not being imported in the generated code.
So instead of keeping a static list of types, I think we can read types from files generated by GodotJS in ./typings to get all types available in godot module. Since godot extensions could also add things to godot module, I don’t think it’s right to use a static list of types.
For extracting type identifiers I suggest we can use an AST tool like tsquery.
Let me know what you think! @nmerget
If we can agree on how to do these, I can start working on it right away.
When I was looking into type generation error of GDScript, I found more issues and have some thoughts on how to improve:
Static methods and properties are not included.
I can help adding static methods and properties to the type generation code. But I noticed the current way of using GDScript in Javascript is not very ergonomic. While generated types help writing code, readability still suffers.
I suggest we can have a function which creates
Proxyobjects that wrap around GDScript classes, so we can use them in a more natural way. So that instead ofgdscript.call("method", parameter), we can writegdscript.method(parameter).godotTsMapis not complete.Resulting in things like
RefCountedandNode3Dnot being imported in the generated code.So instead of keeping a static list of types, I think we can read types from files generated by GodotJS in
./typingsto get all types available ingodotmodule. Since godot extensions could also add things togodotmodule, I don’t think it’s right to use a static list of types.For extracting type identifiers I suggest we can use an AST tool like tsquery.
Let me know what you think! @nmerget
If we can agree on how to do these, I can start working on it right away.