Typescript has two special types,
By default, in Typescript
undefined are assignable to anything, meaning they can be valid values of every type we want to use. Like in the example below:
If we are going to use the
--strictNullChecks mode, the examples above will throw and error and the only types we can assign these two to are
null, undefined and any.
Undefined behaves a bit special and can be assigned to the type
Photo source: Annie Spratt/ @anniespratt on Unsplash