Skip to content

Instantly share code, notes, and snippets.

@sigorilla
Last active February 14, 2018 11:41
Show Gist options
  • Save sigorilla/77a9a87bdd7d6e2f23b56442c1cbad8e to your computer and use it in GitHub Desktop.
Save sigorilla/77a9a87bdd7d6e2f23b56442c1cbad8e to your computer and use it in GitHub Desktop.
DeepPartial<T>
type DeepPartial<T> =
T extends any[] ? DeepPartialArray<T[number]> :
T extends object ? DeepPartialObject<T> :
T;
interface DeepPartialArray<T> extends Array<DeepPartial<T>> { }
type DeepPartialObject<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment