Created
February 2, 2021 12:26
-
-
Save Pwuts/3a41b90f7812dea86c72469f58d6c07d to your computer and use it in GitHub Desktop.
Typescript RecursiveReadonly utility
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 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