What does the `-?` modifier do in a mapped type like `{ [K in keyof T]-?: T[K] }`?

TypeScript Professional Hard

TypeScript Professional — Hard

What does the `-?` modifier do in a mapped type like `{ [K in keyof T]-?: T[K] }`?

Key points

  • The `-?` modifier removes the optional modifier
  • It enforces that all properties must have a value
  • This is useful for ensuring all properties are filled out in a type

Ready to go further?

Related questions