import { IfNoDeepValue } from './helpers.js'; import { IfNever, IfNull } from './type-check.js'; /** * Exclude null and undefined from T deeply */ export type UnNullish = { [K in keyof T as IfNever< Exclude, never, IfNull, never, K> >]: NonNullable; }; /** * Exclude null and undefined from T deeply */ export type DeepUnNullish = { [K in keyof T as IfNever< Exclude, never, IfNull, never, K> >]: IfNoDeepValue< // Do not deep process No-Deep values Exclude > extends true ? NonNullable : // Deep process objects DeepUnNullish>; }; /** * Exclude null and undefined from T deeply including arrays */ export type DeeperUnNullish = { [K in keyof T as IfNever< Exclude, never, IfNull, never, K> >]: NonNullable> extends (infer U)[] ? DeeperUnNullish[] : // Do not deep process No-Deep values IfNoDeepValue> extends true ? NonNullable : // Deep process objects DeeperUnNullish>; };