/** * Helper type that checks if all properties of a type are optional. * * @template T - The type to check */ type AllPropertiesOptional = T extends Partial ? (Partial extends T ? true : false) : false; /** * Type that makes properties optional if all their children are optional. * This is useful for creating types where properties are only optional if their nested properties are all optional. * * @template T - The type to transform * @example * type User = { * name: string; * address?: { * street?: string; * city?: string; * }; * }; * type Transformed = MakePropertyOptionalIfChildrenOptional; * // Result: { name: string; address?: { street?: string; city?: string; } } */ export type MakePropertyOptionalIfChildrenOptional = { [K in keyof T as AllPropertiesOptional extends true ? K : never]?: T[K]; } & { [K in keyof T as AllPropertiesOptional extends true ? never : K]: T[K]; }; export {}; //# sourceMappingURL=makePropertyOptionalIfChildrenOptional.types.d.ts.map