ts-type-forge
    Preparing search index...

    Type Alias TakeLast<N, T>

    TakeLast: IsFixedLengthList<T> extends true ? Tuple.TakeLast<N, T> : T

    Takes the last N elements from a readonly array or tuple T. If T is a tuple, it returns a new tuple containing the last N elements. If T is a general array, it returns the original array type T.

    Type Parameters

    • N extends number

      The number of elements to take.

    • T extends readonly unknown[]

      The readonly array or tuple type.

    A new type containing the last N elements (for tuples) or T (for arrays).

    type TL1 = List.TakeLast<2, [1, 2, 3]>; // readonly [2, 3]
    type TL2 = List.TakeLast<5, [1, 2, 3]>; // readonly [1, 2, 3]
    type TL3 = List.TakeLast<2, readonly string[]>; // readonly string[]