import { IfNoDeepValue } from './helpers.js'; import { IfNever } from './type-check.js'; /** * Make all properties in T nullish */ export type NullishObject = { [K in keyof T as IfNever, never, K>]?: T[K] | null; }; /** * Make all properties in T nullish deeply */ export type DeepNullish = { [K in keyof T as IfNever, never, K>]?: IfNoDeepValue< // Do not deep process No-Deep values Exclude > extends true ? T[K] | null : // Deep process objects DeepNullish> | null; }; /** * Make all properties in T nullish deeply including arrays */ export type DeeperNullish = { [K in keyof T as IfNever, never, K>]?: NonNullable< // Deep process arrays T[K] > extends (infer U)[] ? DeeperNullish[] | null : // Do not deep process No-Deep values IfNoDeepValue> extends true ? T[K] | null : // Deep process objects DeeperNullish> | null; };