microsoft / microsoft/TypeScript
Infer type isn't contextual typed by type bounds
オープン
まだ誰も着手していません。
Bug
Domain: Conditional Types
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
Infer type isn't contextual typed by type bounds
type Foo<T> = T extends string ? Record<T, number> : never;
type Foo2<T extends {a:string}>= T extends {a: infer A} ? Record<A, number>:never; //error here, A should extends string already, but seems not
🔎 Search Terms
generic infer bounds
🕗 Version & Regression Information
4.2.3
⏯ Playground Link
💻 Code
type Foo<T> = T extends string ? Record<T, number> : never;
type Foo2<T extends {a:string}>= T extends {a: infer A} ? Record<A, number>:never; //error here, A should extends string already, but seems not
🙁 Actual behavior
throw error
🙂 Expected behavior
not throw error
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript Playground と縮小された Foo2 の例から始めて、エラーを再現してください。Issue にはソースファイルもテストも指定されていません。コンパイラーが推論された型の境界をどのように処理するかを追跡し、その後、例が期待どおり Record<A, number> を受け入れることを確認して、回帰テストのカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100