UNPKG

412 BTypeScriptView Raw
1/**
2Matches any non-empty tuple.
3
4@example
5```
6import type {NonEmptyTuple} from 'type-fest';
7
8const sum = (...numbers: NonEmptyTuple<number>) => numbers.reduce((total, value) => total + value, 0);
9
10sum(1, 2, 3);
11//=> 6
12
13sum();
14//=> Error: Expected at least 1 arguments, but got 0.
15```
16
17@see {@link RequireAtLeastOne} for objects
18
19@category Array
20*/
21export type NonEmptyTuple<T = unknown> = readonly [T, ...T[]];