UNPKG

618 BTypeScriptView Raw
1import type {UnknownArrayOrTuple} from './internal';
2
3/**
4Extracts the type of an array or tuple minus the first element.
5
6@example
7```
8import type {ArrayTail} from 'type-fest';
9
10declare const curry: <Arguments extends unknown[], Return>(
11 function_: (...arguments_: Arguments) => Return,
12 ...arguments_: ArrayTail<Arguments>
13) => (...arguments_: ArrayTail<Arguments>) => Return;
14
15const add = (a: number, b: number) => a + b;
16
17const add3 = curry(add, 3);
18
19add3(4);
20//=> 7
21```
22
23@category Array
24*/
25export type ArrayTail<TArray extends UnknownArrayOrTuple> = TArray extends readonly [unknown, ...infer Tail] ? Tail : [];