ts-type-forge
    Preparing search index...

    Type Alias Last<T>

    Last: Tuple.Last<T>

    Gets the type of the last element of a readonly array or tuple T. If the array is empty, it returns never.

    Type Parameters

    • T extends readonly unknown[]

      The readonly array or tuple type.

    The type of the last element, or never if T is empty.

    type L1 = List.Last<[1, 2, 3]>; // 3
    type L2 = List.Last<readonly string[]>; // string
    type L3 = List.Last<[]>; // never
    type L4 = List.Last<[1]>; // 1