Created
April 24, 2023 12:38
-
-
Save fostyfost/35cd018f4de60da916993b22fb729aba to your computer and use it in GitHub Desktop.
TypeScript: Recursive partial
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
export type RecursivePartial<T> = { | |
[P in keyof T]?: T[P] extends (infer U)[] | |
? RecursivePartial<U>[] | |
: T[P] extends (...args: any) => any | |
? T[P] | undefined | |
: T[P] extends object | |
? RecursivePartial<T[P]> | |
: T[P] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment