minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @eslint / eslintrc / node_modules / type-fest / source / require-at-least-one.d.ts
1 import {Except} from './except';
2
3 /**
4 Create a type that requires at least one of the given keys. The remaining keys are kept as is.
5
6 @example
7 ```
8 import {RequireAtLeastOne} from 'type-fest';
9
10 type Responder = {
11         text?: () => string;
12         json?: () => string;
13
14         secure?: boolean;
15 };
16
17 const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
18         json: () => '{"message": "ok"}',
19         secure: true
20 };
21 ```
22 */
23 export type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
24         {
25                 // For each Key in KeysType make a mapped type
26                 [Key in KeysType]: (
27                         // …by picking that Key's type and making it required
28                         Required<Pick<ObjectType, Key>>
29                 )
30         }[KeysType]
31         // …then, make intersection types by adding the remaining keys to each mapped type.
32         & Except<ObjectType, KeysType>;