type Mutable = { -readonly [P in keyof T]: T[P]; }; type DeepMutable = T extends object ? { -readonly [P in keyof T]: DeepMutable; } : T; interface Product { readonly id: string; readonly name: string; details: { readonly sku: string; price: number; }; tags: readonly string[]; } type ModifiableProduct = Mutable; // type ModifiableProduct = { id: string; name: string; details: { readonly sku: string; price: number; }; tags: readonly string[]; } // Only top-level readonly removed type FullyModifiableProduct = DeepMutable; /* type FullyModifiableProduct = { id: string; name: string; details: { sku: string; price: number; }; tags: string[]; } */ const product: Readonly = { id: 'p123', name: 'Laptop', details: { sku: 'LTP-XYZ', price: 1200 }, tags: ['electronics', 'computers'] }; // product.id = 'p456'; // Error: Cannot assign to 'id' because it is a read-only property. const modifiableProduct: FullyModifiableProduct = product as FullyModifiableProduct; modifiableProduct.id = 'p456'; // OK modifiableProduct.details.sku = 'LTP-ABC'; // OK modifiableProduct.tags.push('sale'); // OK