PokéRogue
    Preparing search index...

    Type Alias WritableDeep<T>

    WritableDeep: T extends BuiltIns
        ? T
        : T extends (...arguments_: any[]) => unknown
            ? {} extends _WritableObjectDeep<T>
                ? T
                : HasMultipleCallSignatures<T> extends true
                    ? T
                    : (...arguments_: Parameters<T>) => ReturnType<T> & _WritableObjectDeep<
                        T,
                    >
            : T extends ReadonlyMap<unknown, unknown>
                ? WritableMapDeep<T>
                : T extends ReadonlySet<unknown>
                    ? WritableSetDeep<T>
                    : T extends readonly unknown[]
                        ? WritableArrayDeep<T>
                        : T extends object ? _WritableObjectDeep<T> : unknown

    Create a deeply mutable version of an object/ReadonlyMap/ReadonlySet/ReadonlyArray type. The inverse of ReadonlyDeep<T>. Use Writable<T> if you only need one level deep.

    This can be used to store and mutate options within a class, edit readonly objects within tests, construct a readonly object within a function, or to define a single model where the only thing that changes is whether or not some of the keys are writable.

    Type Parameters

    • T
    import type {WritableDeep} from 'type-fest';

    type Foo = {
    readonly a: number;
    readonly b: readonly string[]; // To show that mutability is deeply affected.
    readonly c: boolean;
    };

    const writableDeepFoo: WritableDeep<Foo> = {a: 1, b: ['2'], c: true};
    writableDeepFoo.a = 3;
    writableDeepFoo.b[0] = 'new value';
    writableDeepFoo.b = ['something'];

    Note that types containing overloaded functions are not made deeply writable due to a TypeScript limitation.

    Writable