import type {If} from './if.d.ts'; import type {IfNotAnyOrNever, IsArrayReadonly} from './internal/index.d.ts'; import type {UnknownArray} from './unknown-array.d.ts'; /** Extracts the type of an array or tuple minus the first element. @example ``` import type {ArrayTail} from 'type-fest'; declare const curry: ( function_: (...arguments_: Arguments) => Return, ...arguments_: ArrayTail ) => (...arguments_: ArrayTail) => Return; const add = (a: number, b: number) => a + b; const add3 = curry(add, 3); add3(4); //=> 7 ``` @category Array */ export type ArrayTail = IfNotAnyOrNever extends infer Result ? If, Readonly, Result> : never // Should never happen : never >; type _ArrayTail = TArray extends readonly [unknown?, ...infer Tail] ? keyof TArray & `${number}` extends never ? TArray extends readonly [] ? [] : TArray // Happens when `TArray` is a non-tuple array (e.g., `string[]`) or has a leading rest element (e.g., `[...string[], number]`) : Tail : [];