mirror of
https://github.com/type-challenges/type-challenges.git
synced 2025-12-08 19:06:13 +00:00
Deep Readonly

by Anthony Fu @antfu
Implement a generic DeepReadonly<T> which make every parameter of an object - and its sub-objects recursively - readonly.
Array is not required to be considered in this challenges.
For example
type X = {
x: {
a: 1
b: 'hi'
}
y: 'hey'
}
type Expected = {
readonly x: {
readonly a: 1
readonly b: 'hi'
}
readonly y: 'hey'
}
const todo: DeepReadonly<X> // should be same as `Expaceted`