Narrow the type of the first array element based on the length of the array?

I’m working with an array for which the type of the first element is known, if the array has length one, and which could be one of two types, otherwise; i.e. something like the following: type NarrowableArray<TKnown, TGenereal> = [TKnown] | [TGeneral, TGeneral, …TGeneral[]] type Foo = number | number[] let a: NarrowableArray<number, Foo> =… Read More Narrow the type of the first array element based on the length of the array?