microsoft / microsoft/TypeScript
Interface stop working after passing an optional function attribute
オープン
まだ誰も着手していません。
Bug
Domain: check: Type Inference
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
🕗 Version & Regression Information
- This is the behavior in every version I tried.
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Options<Self extends Options<Self>> {
attr1: Record<string, null>;
attr2: keyof Self["attr1"];
attr3?: (arg: any) => any;
}
function test<T extends Options<T>>(options: T) {
return options
}
test({
attr1: {
a: null,
},
attr2: "a", // here I got the expected auto-completion hint and the type is `a`.
});
test({
attr1: {
a: null,
},
attr2: "a", // here the type is `never` and a problem is caused
attr3: (arg) => arg,
});
🙁 Actual behavior
🙂 Expected behavior
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground を開き、再帰的な Options インターフェイスを使用して test<T extends Options> の 2 つの呼び出しを比較します。オプションの attr3 を追加すると、attr2 が推論されたキーから never に変わる理由を調査します。完了条件は、両方の例で期待される attr2 の型とオートコンプリートの動作が維持され、compiler test suite にリグレッションテストのカバレッジが追加されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100