microsoft / microsoft/TypeScript
Inferred missing properties use resolved generic types rather than staying generic
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.3.0-dev.20181212
Search Terms: declare property generic missing member
Code
class TestClass<T> {
// Inferred:
// otherValue: number;
public constructor(
public readonly value: T,
) { }
}
const foo = new TestClass<number>(1);
foo.otherValue = foo.value;
Expected behavior:
Declare property 'otherValue' should create otherValue: T;
Actual behavior:
...but it actually creates otherValue: number. Whatever generic type from the place you request the missing property be added will be the type of the property.
Related Issues: I found a lot of similar bugs but didn't see any that looked related...
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された TypeScript playground の再現コードを typescript@next で開始し、その挙動が引き続き発生するか確認してください。ジェネリッククラスとインスタンス化された値から、欠落しているプロパティがどのように推論されるかを追跡してください。宣言されたプロパティが number に解決されるのではなく、ジェネリック型 T を保持し、例をカバーするリグレッションテストがあることを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100