source: trip-planner-front/node_modules/type-fest/source/conditional-except.d.ts@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1012 bytes
Line 
1import {Except} from './except';
2import {ConditionalKeys} from './conditional-keys';
3
4/**
5Exclude keys from a shape that matches the given `Condition`.
6
7This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
8
9@example
10```
11import {Primitive, ConditionalExcept} from 'type-fest';
12
13class Awesome {
14 name: string;
15 successes: number;
16 failures: bigint;
17
18 run() {}
19}
20
21type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
22//=> {run: () => void}
23```
24
25@example
26```
27import {ConditionalExcept} from 'type-fest';
28
29interface Example {
30 a: string;
31 b: string | number;
32 c: () => void;
33 d: {};
34}
35
36type NonStringKeysOnly = ConditionalExcept<Example, string>;
37//=> {b: string | number; c: () => void; d: {}}
38```
39*/
40export type ConditionalExcept<Base, Condition> = Except<
41 Base,
42 ConditionalKeys<Base, Condition>
43>;
Note: See TracBrowser for help on using the repository browser.