Skip to content

Instantly share code, notes, and snippets.

@Pwuts
Created February 2, 2021 12:26
Show Gist options
  • Save Pwuts/3a41b90f7812dea86c72469f58d6c07d to your computer and use it in GitHub Desktop.
Save Pwuts/3a41b90f7812dea86c72469f58d6c07d to your computer and use it in GitHub Desktop.
Typescript RecursiveReadonly utility
export type RecursiveReadonly<T extends object> = Readonly<{
readonly [key in keyof T]:
T[key] extends object
? T[key] extends BigInt | Date | Number | Symbol ? T[key] : RecursiveReadonly<T[key]>
: T[key]
}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment