Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_node() function should have generics in TypeScript #126

Open
Terria-K opened this issue May 31, 2022 · 0 comments
Open

get_node() function should have generics in TypeScript #126

Terria-K opened this issue May 31, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Terria-K
Copy link

In C#, we are able to use the simplest and nice <T> as a shortcut and cleaner version of (T) or as to convert the Node into other class that is inherited to Node:

private Sprite sprite;

public override void _Ready() 
{
     sprite = GetNode<Sprite>("path/to/sprite");
}

But in typescript, we are not allowed to write <T> or generics to get_node() like in C#. Instead, we use as to convert the Node into other class that is inherited to Node.

private sprite: godot.Sprite;

public override _ready(): void {
    this.sprite = this.get_node('path/to/sprite') as godot.Sprite;
}

I'd make a workaround by editing the godot.d.ts but it would be nice if it's built-in to the module.

@mageowl mageowl mentioned this issue Aug 10, 2022
31 tasks
@nmerget nmerget added the enhancement New feature or request label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants