From 67ed6552b831df66713bac9e672738796128d33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:10:17 +0200 Subject: Reorganize client shared modules --- shared/core-utils/index.ts | 3 +++ shared/core-utils/logs/index.ts | 1 + shared/core-utils/miscs/index.ts | 3 +++ shared/core-utils/miscs/types.ts | 41 ++++++++++++++++++++++++++++++++++++++ shared/core-utils/plugins/index.ts | 1 + 5 files changed, 49 insertions(+) create mode 100644 shared/core-utils/index.ts create mode 100644 shared/core-utils/logs/index.ts create mode 100644 shared/core-utils/miscs/index.ts create mode 100644 shared/core-utils/miscs/types.ts create mode 100644 shared/core-utils/plugins/index.ts (limited to 'shared/core-utils') diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts new file mode 100644 index 000000000..54e233522 --- /dev/null +++ b/shared/core-utils/index.ts @@ -0,0 +1,3 @@ +export * from './logs' +export * from './miscs' +export * from './plugins' diff --git a/shared/core-utils/logs/index.ts b/shared/core-utils/logs/index.ts new file mode 100644 index 000000000..ceb5d7a7f --- /dev/null +++ b/shared/core-utils/logs/index.ts @@ -0,0 +1 @@ +export * from './logs' diff --git a/shared/core-utils/miscs/index.ts b/shared/core-utils/miscs/index.ts new file mode 100644 index 000000000..afd147f24 --- /dev/null +++ b/shared/core-utils/miscs/index.ts @@ -0,0 +1,3 @@ +export * from './date' +export * from './miscs' +export * from './types' diff --git a/shared/core-utils/miscs/types.ts b/shared/core-utils/miscs/types.ts new file mode 100644 index 000000000..bb64dc830 --- /dev/null +++ b/shared/core-utils/miscs/types.ts @@ -0,0 +1,41 @@ +/* eslint-disable @typescript-eslint/array-type */ + +export type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never +}[keyof T] + +export type FunctionProperties = Pick> + +export type PickWith = { + [P in KT]: T[P] extends V ? V : never +} + +export type PickWithOpt = { + [P in KT]?: T[P] extends V ? V : never +} + +// https://github.com/krzkaczor/ts-essentials Rocks! +export type DeepPartial = { + [P in keyof T]?: T[P] extends Array + ? Array> + : T[P] extends ReadonlyArray + ? ReadonlyArray> + : DeepPartial +} + +type Primitive = string | Function | number | boolean | Symbol | undefined | null +export type DeepOmitHelper = { + [P in K]: // extra level of indirection needed to trigger homomorhic behavior + T[P] extends infer TP // distribute over unions + ? TP extends Primitive + ? TP // leave primitives and functions alone + : TP extends any[] + ? DeepOmitArray // Array special handling + : DeepOmit + : never +} +export type DeepOmit = T extends Primitive ? T : DeepOmitHelper> + +export type DeepOmitArray = { + [P in keyof T]: DeepOmit +} diff --git a/shared/core-utils/plugins/index.ts b/shared/core-utils/plugins/index.ts new file mode 100644 index 000000000..fc78d3512 --- /dev/null +++ b/shared/core-utils/plugins/index.ts @@ -0,0 +1 @@ +export * from './hooks' -- cgit v1.2.3