import { IfNoDeepValue } from './helpers.js'; import { Or } from './logical.js'; import { IfFunction, IfNever } from './type-check.js'; /** * Construct a type with the properties of T except for those in type K, * while preserving strict type checking. */ export type StrictOmit = { [K in keyof T as K extends X ? never : K]: T[K]; }; /** * Omit all function properties in T */ export type OmitFunctions = { [K in keyof T as Or< // Omit never keys IfNever>, // Omit functions IfFunction> > extends true ? never : K]: T[K]; }; /** * Exclude from properties of T those types that are assignable to X */ export type OmitTypes = { [K in keyof T as IfNever, never, K>]: Exclude< T[K], X >; }; /** * Omit all function properties in T */ export type DeepOmitTypes = { [K in keyof T as IfNever< Exclude, never, K >]: IfNoDeepValue> extends true // Do not deep process No-Deep values ? Exclude : // Deep process objects DeepOmitTypes, X>; }; /** * Omit all function properties in T deeply including arrays */ export type DeeperOmitTypes = { [K in keyof T as IfNever< Exclude, never, K >]: NonNullable< // Deep process arrays // Do not deep process No-Deep values T[K] > extends (infer U)[] ? DeeperOmitTypes[] : IfNoDeepValue> extends true ? Exclude : // Deep process objects DeeperOmitTypes, X>; };