vtils

Home > types > WritableDeep

WritableDeep type

Like Writable but recursive

Signature:

export declare type WritableDeep<T> = T extends Builtin
  ? T
  : T extends Map<infer K, infer V>
  ? Map<WritableDeep<K>, WritableDeep<V>>
  : T extends ReadonlyMap<infer K, infer V>
  ? Map<WritableDeep<K>, WritableDeep<V>>
  : T extends WeakMap<infer K, infer V>
  ? WeakMap<WritableDeep<K>, WritableDeep<V>>
  : T extends Set<infer U>
  ? Set<WritableDeep<U>>
  : T extends ReadonlySet<infer U>
  ? Set<WritableDeep<U>>
  : T extends WeakSet<infer U>
  ? WeakSet<WritableDeep<U>>
  : T extends Promise<infer U>
  ? Promise<WritableDeep<U>>
  : T extends {}
  ? {
      -readonly [K in keyof T]: WritableDeep<T[K]>;
    }
  : T;

References: WritableDeep