type-challenges/questions/17973-medium-deepmutable
2022-10-29 22:49:08 +08:00
..
2022-10-26 13:44:40 +08:00
2022-10-26 13:44:40 +08:00
2022-10-29 22:49:08 +08:00

DeepMutable medium #readonly

by cutefcc @cutefcc

Take the Challenge    简体中文

Implement a generic DeepMutable which make every parameter of an object - and its sub-objects recursively - mutable.

For example

type X = {
  readonly a: () => 1
  readonly b: string
  readonly c: {
    readonly d: boolean
    readonly e: {
      readonly g: {
        readonly h: {
          readonly i: true
          readonly j: "s"
        }
        readonly k: "hello"
      }
    }
  }
}

type Expected = {
  a: () => 1
  b: string
  c: {
    d: boolean
    e: {
      g: {
        h: {
          i: true
          j: "s"
        }
        k: "hello"
      }
    }
  }
}

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

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.


Back Share your Solutions Check out Solutions