type-challenges/questions/9-medium-deep-readonly
2020-07-26 08:03:02 +08:00
..
2020-07-26 07:19:46 +08:00
2020-07-26 07:19:46 +08:00
2020-07-26 08:03:02 +08:00
2020-07-26 07:19:46 +08:00
2020-07-26 07:19:46 +08:00

Deep Readonly medium #readonly #object-keys #deep

by Anthony Fu @antfu

Take the Challenge

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`
Back Check out Solutions Share your Solutions