What does the following mapped type do? type Mutable = { -readonly [K in keyof T]: T[K] }

TypeScript Associate Hard

TypeScript Associate — Hard

What does the following mapped type do? type Mutable = { -readonly [K in keyof T]: T[K] }

Key points

  • The mapped type Mutable uses the -readonly modifier to remove the readonly constraint.
  • It operates on each property in type T using the keyof operator.
  • This type transformation is useful for scenarios where mutability is required.

Ready to go further?

Related questions