Type Alias Head<T, Options>

Head<T, Options>: IsNever<T, $SelectionBranch> extends infer R
    ? R extends $Then
        ? Options["$never"]
        : R extends $Else
            ? T["length"] extends 0
                ? Options["caseEmptyTuple"]
                : T[0]
            : never
    : never

🦴 utilities 🔢 customizable

Gets the first entry in the tuple or the type of array T.

Type Parameters

type R = Head<[1, 2, 3]> // 1
type R = Head<string[]> // string

type R = Head<[]> // never

Return type when T is never. Default to never.

Return type when T is []. Default to never.