microsoft / microsoft/TypeScript
[exactOptionalPropertyTypes] Unexpected 'undefined' arises in error message
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
"not assignable", "never", "undefined", "exactOptionalPropertyTypes"
🕗 Version & Regression Information
4.3.5
'undefined' error instead of 'never' ; the value undefined is considered valid
4.4.4, 5.0.4
Expected behavior
5.1.6, 5.7.2
'undefined' error instead of 'never' ; the value undefined triggers the 'never' message
Nightly
not available when testing
⏯ Playground Link
💻 Code
--exactOptionalPropertyTypes
type T =
{ a: number, b?: never } |
{ a?: never, b: number };
const t: T = { // Types of property 'b' are incompatible. Type 'number' is not assignable to type 'undefined'
a: 0,
b: 0
};
🙁 Actual behavior
Type 'number' is not assignable to type 'undefined' is not relevant, since undefined cannot be the type of the t[b].
🙂 Expected behavior
The error should be about type 'number' not being assignable to type 'never'.
It is correctly displayed if the value undefined is used (after the regression at least).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された TypeScript Playground リンクの診断を、exactOptionalPropertyTypes 設定と報告にある union type を使って再現します。記載されたコンパイラーバージョン間で診断を比較します。完了の条件は、number の代入が undefined ではなく never との非互換性を報告し、undefined のケースでは期待される動作が維持されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100