Optionality
This lesson discusses how TypeScript analyses optional values in `if` statements when the `strictNullChecks` flag is enabled.
We'll cover the following...
Defining optionality
As you saw in the previous lesson, strict null checks force you to explicitly distinguish between values that can be null
or undefined
and those that cannot be. You already saw how to do this with a union type.
interface Person {
name: string;
}
let nullableJohn: Person | null;
let maybeUndefinedBob: Person | undefined;
let ambiguoslyEmptyAlice: Person | null | undefined;
Access this course and 1400+ top-rated courses and projects.