-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathextract-rest-element.d.ts
More file actions
30 lines (22 loc) · 785 Bytes
/
extract-rest-element.d.ts
File metadata and controls
30 lines (22 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type {SplitOnRestElement} from './split-on-rest-element.d.ts';
import type {UnknownArray} from './unknown-array.d.ts';
/**
Extract the [`rest`](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) element type from an array.
@example
```
import type {ExtractRestElement} from 'type-fest';
type T1 = ExtractRestElement<[number, ...string[], string, 'foo']>;
//=> string
type T2 = ExtractRestElement<[...boolean[], string]>;
//=> boolean
type T3 = ExtractRestElement<[...Array<'foo'>, true]>;
//=> 'foo'
type T4 = ExtractRestElement<[number, string]>;
//=> never
```
@see {@link ExcludeRestElement}
@see {@link SplitOnRestElement}
@category Array
*/
export type ExtractRestElement<T extends UnknownArray> = SplitOnRestElement<T>[1][number];
export {};