export type DeepPartial<T> = T extends Function ? T : (T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T);
Before [email protected]
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
};
@navix Your solution there is great for typescript 3.0, unfortunately the use of
infer
breaks the ability to get code completion when usingDeepPartial
in argument position (you get type verification only). So for typescript 3.1 and later, the following is much better: