microsoft / microsoft/TypeScript
TypeScript incorrectly infers logical operation result type with empty string
オープン
まだ誰も着手していません。
Bug
Domain: check: Control Flow
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
string logical disjunction type inference string logical inference type infer empty string logical operation type
⏯ Playground Link
Playground link with relevant code
💻 Code
const str: string | undefined = ''
const test = (str || undefined) && {some: 'thing'}
🙁 Actual behavior
Inferred type of operation is
"" | {
some: string;
} | undefined
🙂 Expected behavior
Inferred type of operation is
{
some: string;
} | undefined
because (str || undefined) prevents empty string to be returned
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンク先の TypeScript Playground と、(str || undefined) && {some: 'thing'} を使用するコード例から始めます。予期しない共用体メンバー "" を生成する論理演算の型推論を追跡します。完了条件は、推論される型が { some: string } | undefined, のみになり、この例のカバレッジがあることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100