//#region src/types/DeepPartial.d.ts /** * Makes all properties of `T` optional recursively, unlike the built-in * `Partial` which only affects the first level. * * Recurses into plain objects, arrays/tuples (elements do not become sparse), * and `Map`/`Set` contents. Functions, `Date`, and `RegExp` pass through * unchanged. * * @template T - The type to make deeply optional. * * @example * type Config = { server: { host: string; port: number }; debug: boolean }; * type ConfigPatch = DeepPartial; * // => { server?: { host?: string; port?: number }; debug?: boolean } * * const patch: ConfigPatch = { server: { port: 8080 } }; // ok, host omitted */ type DeepPartial = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends Map ? Map, DeepPartial> : T extends ReadonlyMap ? ReadonlyMap, DeepPartial> : T extends Set ? Set> : T extends ReadonlySet ? ReadonlySet> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial } : T extends object ? { [K in keyof T]?: DeepPartial } : T; //#endregion export { DeepPartial };