import { IfNoDeepValue } from './helpers.js'; import { DeeperOmitRequired, DeeperPickRequired, DeepOmitRequired, DeepPickRequired, OmitRequired, PickRequired, } from './required.js'; import { IfNever } from './type-check.js'; /** * Marks given keys as optional */ export type PartialSome = Partial> & Omit; /** * Partial but deeply */ export type DeepPartial = { [K in keyof T as IfNever, never, K>]?: IfNoDeepValue< // Do not deep process No-Deep values Exclude > extends true ? T[K] : // Deep process objects DeepPartial>; }; /** * Partial but deeply including arrays */ export type DeeperPartial = { [K in keyof T as IfNever, never, K>]?: NonNullable< // Deep process arrays T[K] > extends (infer U)[] ? DeeperPartial[] : // Do not deep process No-Deep values IfNoDeepValue> extends true ? T[K] : // Deep process objects DeeperPartial>; }; /** * OptionalKeys * @desc Returns optional keys of an object */ export type OptionalKeys = keyof PickOptional; /** * Pick all optional properties in T */ export type PickOptional = OmitRequired; /** * Omit all optional properties in T */ export type OmitOptional = PickRequired; /** * Pick all optional properties in T deeply */ export type DeepPickOptional = DeepOmitRequired; /** * Omit all optional properties in T deeply */ export type DeepOmitOptional = DeepPickRequired; /** * Pick all optional properties in T deeply including arrays */ export type DeeperPickOptional = DeeperOmitRequired; /** * Omit all optional properties in T deeply including arrays */ export type DeeperOmitOptional = DeeperPickRequired;