aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/utils.ts')
-rw-r--r--server/typings/utils.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/server/typings/utils.ts b/server/typings/utils.ts
index a86b05be2..24d43b258 100644
--- a/server/typings/utils.ts
+++ b/server/typings/utils.ts
@@ -1,3 +1,22 @@
1export type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T] 1export type FunctionPropertyNames<T> = {
2 [K in keyof T]: T[K] extends Function ? K : never
3}[keyof T]
2 4
3export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> 5export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>
6
7export type PickWith<T, KT extends keyof T, V> = {
8 [P in KT]: T[P] extends V ? V : never
9}
10
11export type PickWithOpt<T, KT extends keyof T, V> = {
12 [P in KT]?: T[P] extends V ? V : never
13}
14
15// https://github.com/krzkaczor/ts-essentials Rocks!
16export type DeepPartial<T> = {
17 [P in keyof T]?: T[P] extends Array<infer U>
18 ? Array<DeepPartial<U>>
19 : T[P] extends ReadonlyArray<infer U>
20 ? ReadonlyArray<DeepPartial<U>>
21 : DeepPartial<T[P]>
22}