-
-
Notifications
You must be signed in to change notification settings - Fork 683
Expand file tree
/
Copy pathvalue-of.d.ts
More file actions
24 lines (17 loc) · 730 Bytes
/
value-of.d.ts
File metadata and controls
24 lines (17 loc) · 730 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
/**
Create a union of the given object's values, and optionally specify which keys to get the values from.
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
@example
```
import type {ValueOf} from 'type-fest';
type A = ValueOf<{id: number; name: string; active: boolean}>;
//=> string | number | boolean
type B = ValueOf<{id: number; name: string; active: boolean}, 'name'>;
//=> string
type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
//=> string | number
```
@category Object
*/
export type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
export {};