microsoft / microsoft/TypeScript
Narrow the parent type of a singleton type to never in the false branch
オープン
まだ誰も着手していません。
In Discussion
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
If the type of the member checked is not falsy (and so is never in the false branch).
TypeScript Version: 2.7.0-dev.201xxxxx
Code
const x: {a: 1, b: 2} = { a: 1, b: 2 };
if (x.a) {
}
else {
x.a;
}
Expected behavior:
type of x in the else branch is never.
Actual behavior:
type of x is {a: 1. b: 2}, and x.a is (counterintuitively) never.
This would bring the behavior of truthiness guards in line with our new behavior for in type guards.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された例を TypeScript compiler で再現します。要求どおり、できれば typescript@next に対して実行してください。truthiness-guard の narrowing の挙動を追跡し、記載されている in type-guard の挙動と比較します。x が false 分岐で never に絞り込まれ、同時に x.a の期待される型が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100