/** * 深度去除null和undefined * @example * 输入: * type Example = { * first: { * second: { * name: string; * }; * }; * }; * type example = DeepNonNullable * 输出: * type example = { * first?: null | { * second?: null | { * name?: string | null | * undefined; * }; * }; */ export type DeepNonNullable = T extends (...args: any[]) => any ? T : T extends any[] ? DeepNonNullableArray : T extends object ? DeepNonNullableObject : T; export interface DeepNonNullableArray extends Array>> { } export type DeepNonNullableObject = { [P in keyof T]-?: DeepNonNullable>; };