-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: exactOptionalPropertyTypesBugs specific to enabling this flagBugs specific to enabling this flagHelp WantedYou can do thisYou can do this
Milestone
Description
🔎 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).
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: exactOptionalPropertyTypesBugs specific to enabling this flagBugs specific to enabling this flagHelp WantedYou can do thisYou can do this