From 6b5f72beda96d8b7e4d6329c4001827334de27dd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Dec 2021 18:04:16 +0100 Subject: Move typescript utils in its own directory --- shared/core-utils/common/index.ts | 1 - shared/core-utils/common/types.ts | 45 ----------------------------- shared/extra-utils/server/config-command.ts | 2 +- 3 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 shared/core-utils/common/types.ts (limited to 'shared') 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' export * from './miscs' export * from './regexp' export * from './promises' -export * from './types' 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 @@ -/* 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 AttributesOnly = { - [K in keyof T]: T[K] extends Function ? never : T[K] -} - -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/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts index a061ca89e..89ae8eb4f 100644 --- a/shared/extra-utils/server/config-command.ts +++ b/shared/extra-utils/server/config-command.ts @@ -1,5 +1,5 @@ import { merge } from 'lodash' -import { DeepPartial } from '@shared/core-utils' +import { DeepPartial } from '@shared/typescript-utils' import { About, HttpStatusCode, ServerConfig } from '@shared/models' import { CustomConfig } from '../../models/server/custom-config.model' import { AbstractCommand, OverrideCommandOptions } from '../shared' -- cgit v1.2.3