.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / type-fest / source / conditional-pick.d.ts
1 import {ConditionalKeys} from './conditional-keys';
2
3 /**
4 Pick keys from the shape that matches the given `Condition`.
5
6 This is useful when you want to create a new type from a specific subset of an existing type. For example, you might want to pick all the primitive properties from a class and form a new automatically derived type.
7
8 @example
9 ```
10 import {Primitive, ConditionalPick} from 'type-fest';
11
12 class Awesome {
13         name: string;
14         successes: number;
15         failures: bigint;
16
17         run() {}
18 }
19
20 type PickPrimitivesFromAwesome = ConditionalPick<Awesome, Primitive>;
21 //=> {name: string; successes: number; failures: bigint}
22 ```
23
24 @example
25 ```
26 import {ConditionalPick} from 'type-fest';
27
28 interface Example {
29         a: string;
30         b: string | number;
31         c: () => void;
32         d: {};
33 }
34
35 type StringKeysOnly = ConditionalPick<Example, string>;
36 //=> {a: string}
37 ```
38 */
39 export type ConditionalPick<Base, Condition> = Pick<
40         Base,
41         ConditionalKeys<Base, Condition>
42 >;