The object type to make mutable.
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 }
Makes all properties of an object type
Tmutable by removing thereadonlymodifier. This utility is the opposite of TypeScript's built-inReadonly<T>utility type.Uses the
-readonlymodifier syntax to explicitly remove readonly modifiers from all properties at the top level of the object type.