Create a type that makes the given keys readonly. The remaining keys are kept as is.
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are readonly.
import type {SetReadonly} from 'type-fest';type Foo = { a: number; readonly b: string; c: boolean;}type SomeReadonly = SetReadonly<Foo, 'b' | 'c'>;// type SomeReadonly = {// a: number;// readonly b: string; // Was already readonly and still is.// readonly c: boolean; // Is now readonly.// } Copy
import type {SetReadonly} from 'type-fest';type Foo = { a: number; readonly b: string; c: boolean;}type SomeReadonly = SetReadonly<Foo, 'b' | 'c'>;// type SomeReadonly = {// a: number;// readonly b: string; // Was already readonly and still is.// readonly c: boolean; // Is now readonly.// }
Create a type that makes the given keys readonly. The remaining keys are kept as is.
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are readonly.