Closed
Description
π Search Terms
Rest Element
Tuples
Leading Rest Element Tuple
π Version & Regression Information
Nightly
β― Playground Link
π» Code
type T = [...string[], number, boolean, symbol];
type First = T[0];
π Actual behavior
type T = [...string[], number, boolean, symbol];
type First = T[0];
// ^? First = string | number | boolean | symbol
π Expected behavior
type T = [...string[], number, boolean, symbol];
type First = T[0];
// ^? First = string | number
Additional information about the issue
Is this a common thing it doesn't make sense, like T[0]
can never be boolean or symbol am I missing something.
Although I can be used to create type guard to check for leading rest element in arrays.
type IsLeadingRestElement<T extends UnknownArray> = If<IsAny<T>, false,
number extends T['length']
? T[number] extends T[0]
? true
: false
: false
>;
Metadata
Metadata
Assignees
Labels
No labels