exactOptionalPropertyTypes
The compiler option that forbids setting an optional property to undefined explicitly, so it must be omitted or given a real value.
In more detail
It lets the types tell apart a key that is missing from one that is present but undefined, which matters when a missing key means leave unchanged. It is not part of strict and must be enabled separately.
Related terms
- optional property — An object property marked with a question mark, such as bio?: string, which may be left out.
- undefined — The JavaScript value meaning not set: a variable with no value yet, a missing property or a function that returned nothing.
- hasOwnProperty — A check that tells whether an object has a property itself, rather than inheriting it, even when its value is undefined.
Taught in
- void, undefined And null: Exact Optional Property Types — Production TypeScript