One recommended option exactOptionalPropertyTypes is not well known, especially to TypeScript beginners, because strict does not include it. However, it’s crucial and will cause runtime errors where you don’t expect them.
This option makes such a code invalid and shows a type error:
With this option, to allow setting undefined to an optional field, you have to specify it explicitly:
At first glance, it might seem like a nuisance, but consider the following example:
The code above would be valid without the option, but it would set the user into an impossible state and ultimately cause runtime errors.