I want to create a type with a condition based on never
but I the results are unexpected (Typescript version 4.1.3).
type TypeCond<T, U> = T extends never ? {a: U} : {b: U};
let test: TypeCond<never, number>;
I have the TypeCond
that has a simple condition if T
extends never
.
I would expect that the type of the test
variable will be {a: number}
but actually, the type is never
.
I'm not sure why... If I replace the never
with undefined
or null
it works as expected. But I need the condition for the never
type.
Any idea why test
gets a never
type instead of {a: number}
?