TypeScript 2.8 introduced a few operators that allow us to have a greater level of control over the definition of mapped types:
- We can use the readonly modifier to flag a property as immutable.
- We can use the ? operator to flag a property as optional.
- We can use the + operator to apply a modifier, such as the readonly modifier, to a property in a type. We can also use the + operator with the ? operator.
- We can use the - operator to apply a modifier, such as the readonly modifier to a property in a type. We can also use the + operator with the ? operator.
We will now examine a few examples. The code snippet declares a mapped type that can be used to transform a type, T, into a new type that contains all the properties ...