Type alias HeadAndTail<Input>
HeadAndTail<Input>: Input extends readonly [head
: infer HeadItem, tail
: infer TailItems] ? readonly [head
: HeadItem, tail
: TailItems] : Input extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [head
: FirstCharacter, tail
: RestOfString] : Input extends EmptyArray | EmptyString ? readonly [head
: undefined, tail
: Input] : readonly [head
: Maybe<Input[number]>, tail
: Input]
Get a couple with the head and tail types of an
ArrayLike
.Remarks
Given a type argument (an
ArrayLike
), this returns a couple with the type of the item in index0
first, and the rest of theArrayLike
after.Example
See