-
-
Notifications
You must be signed in to change notification settings - Fork 675
Expand file tree
/
Copy patharray-values.d.ts
More file actions
24 lines (16 loc) · 660 Bytes
/
array-values.d.ts
File metadata and controls
24 lines (16 loc) · 660 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
/**
Provides all values for a constant array or tuple.
Use-case: This type is useful when working with constant arrays or tuples and you want to enforce type-safety with their values.
@example
```
import type {ArrayValues, ArrayIndices} from 'type-fest';
const weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as const;
type WeekdayName = ArrayValues<typeof weekdays>;
type Weekday = ArrayIndices<typeof weekdays>;
const getWeekdayName = (day: Weekday): WeekdayName => weekdays[day];
```
@see {@link ArrayIndices}
@category Array
*/
export type ArrayValues<T extends readonly unknown[]> = T[number];
export {};