TypeScript · Junior · Question 28 of 75
What does strictNullChecks give you?
- ✓Correct answer:
nullandundefinedbecome separate types that must be handled explicitly - 2It forbids
nullin code entirely, allowing onlyundefined - 3It automatically replaces
nullwithundefinedwhen compiling to JS
Explanation
Without the flag, null can be assigned to anything, and "cannot read property of null" errors aren't caught. With it, string doesn't include null: you write string | null and check the value before use. It's one of the most useful flags.