ts-type-forge
    Preparing search index...
    Last: T extends readonly []
        ? never
        : T extends readonly [unknown] ? Tuple.Head<T> : Tuple.Last<Tuple.Tail<T>>

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

    Type Parameters

    • T extends readonly unknown[]

      The readonly tuple type.

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

    type L1 = Tuple.Last<[1, 2, 3]>; // 3
    type L2 = Tuple.Last<[]>; // never
    type L3 = Tuple.Last<[1]>; // 1