Closed
Description
π Search Terms
never, intersection, contradiction
π Version & Regression Information
- This changed in commit or PR Reduce intersections by discriminantsΒ #36696
β― Playground Link
π» Code
type IsNumber<T> = T extends number ? true : false
type Conflicted = {x:true} & {x:false} // never
// ^?
type Ex1 = IsNumber<Conflicted> // true. Should be never
// ^?
type Ex2 = IsNumber<never>
// ^?
// Conflicted starts behaving like `never` again when distributivity is forced by putting it in a union
type Ex3 = IsNumber<"OEEE" | Conflicted> // false (boolean in TypeScript 4.6.4)
// ^?
type Ex4 = IsNumber<1 | Conflicted> // true
// ^?
π Actual behavior
Ex1
is true
.
π Expected behavior
IsNumber<Conflicted>
should be never
. This is a distributive conditional.
Additional information about the issue
This also manifests as ReturnType<T>
being unknown
when T
is a conflicted intersection.
Originally submitted in #57210 which was overly broad.