Skip to content

Instantly share code, notes, and snippets.

@isthatcentered
isthatcentered / DeepPartial.ts
Last active June 19, 2020 05:26
Typescript - Deep Partial
https://stackoverflow.com/questions/45372227/how-to-implement-typescript-deep-partial-mapped-type-not-breaking-array-properti/49936686#49936686
export 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]>
};