TypeScript · Types and shapes
null and undefined
With strictNullChecks, null and undefined are separate types and must be handled explicitly.
Syntax
string | nullExample
Example
type Maybe = string | null;
function len(value: Maybe) {
return value ? value.length : 0;
}More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.