diff options
Diffstat (limited to 'shared/core-utils')
-rw-r--r-- | shared/core-utils/common/index.ts | 1 | ||||
-rw-r--r-- | shared/core-utils/common/types.ts | 45 |
2 files changed, 0 insertions, 46 deletions
diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.ts index 0908ff981..5d3512148 100644 --- a/shared/core-utils/common/index.ts +++ b/shared/core-utils/common/index.ts | |||
@@ -2,5 +2,4 @@ export * from './date' | |||
2 | export * from './miscs' | 2 | export * from './miscs' |
3 | export * from './regexp' | 3 | export * from './regexp' |
4 | export * from './promises' | 4 | export * from './promises' |
5 | export * from './types' | ||
6 | export * from './url' | 5 | export * from './url' |
diff --git a/shared/core-utils/common/types.ts b/shared/core-utils/common/types.ts deleted file mode 100644 index bd2a97b98..000000000 --- a/shared/core-utils/common/types.ts +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/array-type */ | ||
2 | |||
3 | export type FunctionPropertyNames<T> = { | ||
4 | [K in keyof T]: T[K] extends Function ? K : never | ||
5 | }[keyof T] | ||
6 | |||
7 | export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> | ||
8 | |||
9 | export type AttributesOnly<T> = { | ||
10 | [K in keyof T]: T[K] extends Function ? never : T[K] | ||
11 | } | ||
12 | |||
13 | export type PickWith<T, KT extends keyof T, V> = { | ||
14 | [P in KT]: T[P] extends V ? V : never | ||
15 | } | ||
16 | |||
17 | export type PickWithOpt<T, KT extends keyof T, V> = { | ||
18 | [P in KT]?: T[P] extends V ? V : never | ||
19 | } | ||
20 | |||
21 | // https://github.com/krzkaczor/ts-essentials Rocks! | ||
22 | export type DeepPartial<T> = { | ||
23 | [P in keyof T]?: T[P] extends Array<infer U> | ||
24 | ? Array<DeepPartial<U>> | ||
25 | : T[P] extends ReadonlyArray<infer U> | ||
26 | ? ReadonlyArray<DeepPartial<U>> | ||
27 | : DeepPartial<T[P]> | ||
28 | } | ||
29 | |||
30 | type Primitive = string | Function | number | boolean | Symbol | undefined | null | ||
31 | export type DeepOmitHelper<T, K extends keyof T> = { | ||
32 | [P in K]: // extra level of indirection needed to trigger homomorhic behavior | ||
33 | T[P] extends infer TP // distribute over unions | ||
34 | ? TP extends Primitive | ||
35 | ? TP // leave primitives and functions alone | ||
36 | : TP extends any[] | ||
37 | ? DeepOmitArray<TP, K> // Array special handling | ||
38 | : DeepOmit<TP, K> | ||
39 | : never | ||
40 | } | ||
41 | export type DeepOmit<T, K> = T extends Primitive ? T : DeepOmitHelper<T, Exclude<keyof T, K>> | ||
42 | |||
43 | export type DeepOmitArray<T extends any[], K> = { | ||
44 | [P in keyof T]: DeepOmit<T[P], K> | ||
45 | } | ||