What does ‘-?’ do in a mapped type like { [K in keyof T]-?: T[K] }?

TypeScript Associate Hard

TypeScript Associate — Hard

What does ‘-?’ do in a mapped type like { [K in keyof T]-?: T[K] }?

Key points

  • The '-?' operator in TypeScript mapped types removes the optional modifier
  • This enforces that all properties in the mapped type are required
  • It ensures that properties cannot be left undefined or null

Ready to go further?

Related questions