/** * 深度设置为可选 * @example * 输入: * type Example = { * first: { * second: { * name: string; * }; * }; * }; * type example = DeepPartial; * 输出: * type example = { * first?:{ * second?:{ * name?:string * } * } * } */ export type DeepPartial = T extends Function ? T : T extends Array ? DeepPartialArray : T extends object ? DeepPartialObject : T | undefined; export interface DeepPartialArray extends Array> { } export type DeepPartialObject = { [P in keyof T]?: DeepPartial; };