ts-type-forge
    Preparing search index...

    Type Alias Head<T, D>

    Head: Tuple.Head<T, D>

    Gets the type of the first element of a readonly array or tuple T. If the array is empty, it returns the default type D (defaults to never). Delegates to Tuple.Head.

    Type Parameters

    • T extends readonly unknown[]

      The readonly array or tuple type.

    • D = never

      The default type to return if T is empty. Defaults to never.

    The type of the first element, or D if T is empty.

    type H1 = List.Head<[1, 2, 3]>; // 1
    type H2 = List.Head<readonly string[]>; // string
    type H3 = List.Head<[]>; // never
    type H4 = List.Head<[], 'default'>; // 'default'