Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 2.8 KB

File metadata and controls

29 lines (22 loc) · 2.8 KB

Deep Readonly medium #readonly #object-keys #deep

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語 한국어 Português (BR)

Implement a generic DeepReadonly<T> which make every parameter of an object - and its sub-objects recursively - readonly.

You can assume that we are only dealing with Objects in this challenge. Arrays, Functions, Classes and so on do not need to be taken into consideration. However, you can still challenge yourself by covering as many different cases as possible.

For example:

type X = { 
  x: { 
    a: 1
    b: 'hi'
  }
  y: 'hey'
}

type Expected = { 
  readonly x: { 
    readonly a: 1
    readonly b: 'hi'
  }
  readonly y: 'hey' 
}

type Todo = DeepReadonly<X> // should be same as `Expected`

Back Share your Solutions Check out Solutions

Related Challenges

7・Readonly 8・Readonly 2