How does TypeScript handle null and undefined?
Instruction: Explain how TypeScript treats null and undefined values, including any configuration options that affect their handling.
Context: This question examines the candidate's knowledge of TypeScript's type system, specifically its treatment of null and undefined values.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
With strictNullChecks enabled, null and undefined have distinct types and must be handled when a value's type includes them. A string is different from string | undefined. When the option is disabled, those absence values are broadly assignable and many useful null checks disappear from the static model; JavaScript runtime behavior does not change.
Check the effective compiler configuration rather than assuming a timeless default...