ts-type-forge
    Preparing search index...

    Type Alias DeepMutable<T>

    DeepMutable: T extends Primitive
        ? T
        : T extends AnyFn
            ? T
            : T extends MutableMap<infer K, infer V>
                ? MutableMap<DeepMutable<K>, DeepMutable<V>>
                : T extends ReadonlyMap<infer K, infer V>
                    ? MutableMap<DeepMutable<K>, DeepMutable<V>>
                    : T extends MutableSet<infer V>
                        ? MutableSet<DeepMutable<V>>
                        : T extends ReadonlySet<infer V>
                            ? MutableSet<DeepMutable<V>>
                            : T extends Record<string, any>
                            | readonly unknown[]
                                ? { -readonly [K in keyof T]: DeepMutable<T[K]> }
                                : T

    Recursively removes the readonly modifier from all properties of an object, array, Map, or Set. Primitives and functions are returned as is.

    Type Parameters

    • T

      The type to make deeply mutable.

    A new type with all nested readonly modifiers removed.

    type ReadonlyData = { readonly a: number; readonly b: { readonly c: readonly string[] } };
    type MutableData = DeepMutable<ReadonlyData>;
    // Result: { a: number; b: { c: string[] } }