Skip to content

Latest commit

 

History

History
47 lines (40 loc) · 2.13 KB

File metadata and controls

47 lines (40 loc) · 2.13 KB

DeepMutable medium #readonly #deep

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