Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (18 sloc) 871 Bytes
Convert an object with `readonly` properties into a mutable object. Inverse of `Readonly<T>`.
This can be used to [store and mutate options within a class](, [edit `readonly` objects within tests](, and [construct a `readonly` object within a function](
import {Mutable} from 'type-fest';
type Foo = {
readonly a: number;
readonly b: string;
const mutableFoo: Mutable<Foo> = {a: 1, b: '2'};
mutableFoo.a = 3;
export type Mutable<ObjectType> = {
// For each `Key` in the keys of `ObjectType`, make a mapped type by removing the `readonly` modifier from the property.
-readonly [KeyType in keyof ObjectType]: ObjectType[KeyType];
You can’t perform that action at this time.