Skip to content

Instantly share code, notes, and snippets.

Created February 7, 2023 22:51
What would you like to do?
Recursive Type Example
type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> };
type DeepReadonly<T> = T extends (infer E)[] ?
ReadonlyArray<ReadonlyArray<DeepReadonlyObject<E>>> :
T extends object ? DeepReadonlyObject<T> :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment