microsoft / microsoft/TypeScript
`x && x` should not be `NonNullable`
オープン
まだ誰も着手していません。
Bug
Domain: check: Control Flow
Help Wanted
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
🔎 Search Terms
logical and, generic, NonNullable
🕗 Version & Regression Information
There has been this problem since 4.8.4 (I tried it on the playground)
⏯ Playground Link
💻 Code
const f = <T,>(x: T) => x && x // <T>(x: T) => NonNullable<T>
🙁 Actual behavior
Since f returns NonNullable<T>, we can make every value NonNullable, and never can be created by calling f(null).
🙂 Expected behavior
f should return T.
Additional information about the issue
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の再現コードから始め、型チェッカーがジェネリックな論理 AND 式の戻り値の型をどのように推論するかを調べます。示されているジェネリック関数での動作を検証し、結果の型が報告された NonNullable と never の結果をもはや許可しないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100