With strictNullChecks, null and undefined are not assignable unless the type allows them. Use optional chaining ?. and nullish coalescing ??.
Defensive patterns
value ?? default only replaces null/undefined, not 0 or ''. Combine with explicit guards when empty string is invalid.
Self-check
- Explain difference between
||and??with an example.
Optional properties (nickname?: string) differ from string | undefined when exact optional property types are enabled in strict config.
Practice: Apply nullability in the playground, then explain nullability in one sentence without looking at notes.