get_node() function should have generics in TypeScript
- 主要言語
- C++
- スター
- 1.1k
- フォーク
- 80
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
In C#, we are able to use the simplest and nice `` as a shortcut and cleaner version of `(T)` or `as` to convert the Node into other class that is inherited to Node:
```csharp
private Sprite sprite;
public override void _Ready()
{
sprite = GetNode("path/to/sprite");
}
```
But in typescript, we are not allowed to write `` or generics to `get_node()` like in C#. Instead, we use `as` to convert the Node into other class that is inherited to Node.
```typescript
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.
コントリビューションガイド
調査の方向性
godot.d.ts から始めて、issue に記載されている get_node() の宣言を見つけます。その宣言を更新して、呼び出し側が返される Node 型の TypeScript ジェネリックを指定できるようにし、その後、例で as cast が不要になっていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- game-dev
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100