UNPKG

1.14 kBTypeScriptView Raw
1import { Builtin } from "../built-in";
2import { IsTuple } from "../is-tuple";
3import { IsUnknown } from "../is-unknown";
4export type DeepPartial<Type> = Type extends Exclude<Builtin, Error> ? Type : Type extends Map<infer Keys, infer Values> ? Map<DeepPartial<Keys>, DeepPartial<Values>> : Type extends ReadonlyMap<infer Keys, infer Values> ? ReadonlyMap<DeepPartial<Keys>, DeepPartial<Values>> : Type extends WeakMap<infer Keys, infer Values> ? WeakMap<DeepPartial<Keys>, DeepPartial<Values>> : Type extends Set<infer Values> ? Set<DeepPartial<Values>> : Type extends ReadonlySet<infer Values> ? ReadonlySet<DeepPartial<Values>> : Type extends WeakSet<infer Values> ? WeakSet<DeepPartial<Values>> : Type extends ReadonlyArray<infer Values> ? Type extends IsTuple<Type> ? {
5 [Key in keyof Type]?: DeepPartial<Type[Key]>;
6} : Type extends Array<Values> ? Array<DeepPartial<Values> | undefined> : ReadonlyArray<DeepPartial<Values> | undefined> : Type extends Promise<infer Value> ? Promise<DeepPartial<Value>> : Type extends {} ? {
7 [Key in keyof Type]?: DeepPartial<Type[Key]>;
8} : IsUnknown<Type> extends true ? unknown : Partial<Type>;