Skip to content

Instantly share code, notes, and snippets.

@fostyfost
Created April 24, 2023 12:38
Show Gist options
  • Save fostyfost/35cd018f4de60da916993b22fb729aba to your computer and use it in GitHub Desktop.
Save fostyfost/35cd018f4de60da916993b22fb729aba to your computer and use it in GitHub Desktop.
TypeScript: Recursive partial
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