godotjs / godotjs/javascript

get_node() function should have generics in TypeScript

オープン
#126 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る
enhancement
主要言語
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。