Last active
August 5, 2020 19:46
-
-
Save Drag13/77663909e751ab35161cf7468f0ae3a8 to your computer and use it in GitHub Desktop.
Deep Partial Type in TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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