I was expecting a conflicting type intersection to produce a type of never
. What am I missing?
type A = {value: string}
type B = {value: number}
type D = A & B
type E<T> = T extends never ? 'never' : 'something';
type F = E<D> // expected 'never', got 'something';
It's only the conflicting property that has the never
type, not the entire object type D
(other properties in the type might be just fine, after all). So D["value"]
is never
, but not D
:
type A = {value: string}
type B = {value: number}
type D = A & B
type E<T> = T extends never ? 'never' : 'something';
type F = E<D>;
// ^?−− type F = "something"
type F2 = E<D["value"]>;
// ^?−− type F2 = "never"