ts-type-forge
    Preparing search index...

    Type Alias Mutable<T>

    Mutable: { -readonly [P in keyof T]: T[P] }

    Makes all properties of an object type T mutable by removing the readonly modifier. This utility is the opposite of TypeScript's built-in Readonly<T> utility type.

    Uses the -readonly modifier syntax to explicitly remove readonly modifiers from all properties at the top level of the object type.

    Type Parameters

    • T

      The object type to make mutable.

    An object type with all readonly modifiers removed.

    type ReadonlyUser = {
    readonly id: number;
    readonly name: string;
    readonly email: string;
    };

    type MutableUser = Mutable<ReadonlyUser>;
    // Result: { id: number; name: string; email: string }

    const user: MutableUser = { id: 1, name: "Alice", email: "alice@example.com" };
    user.name = "Alice Smith"; // ✓ allowed - property is mutable

    // Useful for creating editable versions of readonly data
    type Config = Readonly<{ host: string; port: number; ssl: boolean }>;
    type EditableConfig = Mutable<Config>; // { host: string; port: number; ssl: boolean }