PickFromKeys<O, K>
ts
type PickFromKeys<O, K> = { [P in K[number]]: O[P] };Defined in: types.ts:215
Creates a new type by picking only the properties specified in the keys array from object. Similar to Pick, but accepts a readonly array of keys.
Type Parameters
| Type Parameter | Description |
|---|---|
O | The object type to pick from |
K extends ReadonlyArray<keyof O> | A readonly array of keys to pick |
Example
ts
type Original = {
a: string
b: number
c: boolean
};
type Result = PickFromKeys<Original, ['a', 'c']>;
// Result: { a: string; c: boolean }