Skip to content

Instantly share code, notes, and snippets.

@Drag13
Last active August 5, 2020 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drag13/77663909e751ab35161cf7468f0ae3a8 to your computer and use it in GitHub Desktop.
Save Drag13/77663909e751ab35161cf7468f0ae3a8 to your computer and use it in GitHub Desktop.
Deep Partial Type in TypeScript
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]>;
};
// Credits goes to the https://stackoverflow.com/!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment