Lesson overview · Free interview practice

Advanced Types

Learn union types, intersections, and type guards.

Topics in the full lesson
  • Introduction to Advanced Types
  • Union Types
  • Intersection Types
  • Type Guards
  • Type Narrowing
  • Type Predicates
  • Type Compatibility and Assignability
  • Type Assertions and Casting
  • Best Practices
  • Exercises

Practice Problems

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Completion marks record your own progress, not an automatically checked result. The task type does not determine whether it is optional.

TheoryEasy

Union Types

Question

What is a union type in TypeScript? Show how TS narrows union members and the basic assignability rules.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Intersection Types

Question

What is an intersection type? Compare with interface extension. When does intersection collapse to never?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Control-Flow Analysis: How TS Narrows Across Statements

Question

What is control-flow analysis in TypeScript? Show how TS narrows a variable's type across assignments, conditions, and throws.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

The `satisfies` Operator (TS 4.9)

Question

What does the satisfies operator do? Show how it differs from a type annotation and from as. What problem does it solve?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryHard

Branded Types: Nominal Typing on a Structural Base

Question

What are branded types in TypeScript, and what problem do they solve? Show three implementation styles.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Advanced Types material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium