Type Narrowing
This section covers using runtime evidence and control flow to refine broad static types. Every lesson stands alone while fitting the beginner-to-staff progression.
Learning outcomes
- Explain runtime and compile-time responsibilities.
- Write a correct example without unsafe escape hatches.
- Diagnose a representative compiler error.
- Identify API, performance, security, and production trade-offs.
- Apply the concept in a project or interview.
Lessons
- typeof Narrowing
- Truthiness Narrowing
- Equality Narrowing
- in Operator Narrowing
- instanceof Narrowing
- Assignment Narrowing
- Control Flow Analysis
- User-Defined Type Guards
- Type Predicates
- Assertion Functions
- Discriminated Unions
- Exhaustiveness Checking
- never Checks
Study method
Run the examples under strict checking, intentionally introduce an error, explain the diagnostic, and finish the exercises.