Nullable Types | Typescript
Optional parameters and properties#
With --strictNullChecks, an optional parameter automatically adds | undefined:
Type guards and type assertions#
In cases where the compiler can't eliminate null or undefined, you can use the type assertion operator to manually remove them.
The syntax is postfix !: identifier! removes null and undefined from the type of identifier: