Skip to content

Thoughts on improving GDScript codegen #545

@hi94740

Description

@hi94740

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions