ts-type-forge
    Preparing search index...

    Type Alias SkipLast<N, T>

    SkipLast: TSTypeForgeInternals_PinsOneNumber<N> extends true
        ? SkipLastImpl<N, T, readonly []>
        : readonly T[number][]

    Skips the last N elements from a readonly tuple T.

    Type Parameters

    • N extends number

      The number of elements to skip. Only a single numeric literal pins a length; a union of literals and number alike answer an unsized array, which every possible result satisfies.

    • T extends readonly unknown[]

      The readonly tuple type.

    A new readonly tuple type containing the elements before the last N. If N is larger than the length of T, returns readonly [].

    type SL1 = Tuple.SkipLast<1, [1, 2, 3]>; // readonly [1, 2]
    type SL2 = Tuple.SkipLast<3, [1, 2, 3]>; // readonly []
    type SL3 = Tuple.SkipLast<0, [1, 2, 3]>; // readonly [1, 2, 3]
    type SL4 = Tuple.SkipLast<1 | 2, [1, 2, 3]>; // readonly (1 | 2 | 3)[]
    type SL5 = Tuple.SkipLast<number, [1, 2, 3]>; // readonly (1 | 2 | 3)[]