types-kit.mutabledeep.md

September 4, 2023 ยท View on GitHub

Home > types-kit > MutableDeep

MutableDeep type

Make all properties (includes deep properties) in T mutable (remove readonly decorator) .

Signature:

export type MutableDeep<T> = {
  -readonly [P in keyof T]: MutableDeep<T[P]>
}

References: MutableDeep

Example

interface Props {
     readonly a: {
       readonly d: number
     };
     readonly b: number;
     readonly c: number;
   };
  // Expect: { a: { d: number }; b: number; c: number; }
  type NewProps = MutableDeep<Props>;