-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped typesFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
When trying to remove nils from a Tuple it resolves to an Tuple that do not extends to the identical Tuple (as represented by the compiler)
So in the example below the reult of a type is [a: 1, b?:2] which do not extends the type [a: 1, b?:2] ??
🔎 Search Terms
Identical type - Invalid Equality
tuple optional extends
🕗 Version & Regression Information
Discovered the issue today and it's referenced on the following stackoverflow
I did test it in the playground upto version 4.05 of typescript (syntax breaks in version prior)
⏯ Playground Link
💻 Code
type UnNullify<T extends readonly unknown[]> = {
[K in keyof T]: Exclude<T[K], null | undefined>
}
type Foo = UnNullify<[a: 1, b?: 2 | undefined]>
// [a: 1, b?: 2]
type Test = [a: 1, b?: 2] extends Foo ? true : false
// false ??🙁 Actual behavior
Two types represented identical by the compiler do not extends each other
🙂 Expected behavior
Expected the two types to extends
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped typesFix AvailableA PR has been opened for this issueA PR has been opened for this issue