I got this type from the TS handbook:
type ToArray<Type> = Type extends any ? Type[] : never;
If you evaluate ToArray<string & number>
, you get never
;
However, if you evaluate type Thing = (string & number) extends any ? never[] : never;
, Thing
ends up as type never[]
.
Why?
I've also tried writing out some more examples and none if it seems to help me understand:
type Thing = string & number; // type never
type OtherThing = Thing extends any ? Thing[] : never; // type never[]
type OtherOtherThing = ToArray<Thing>; // type never