Lesson overview · Free interview practice

Conditional Types

Master mapped and conditional type expressions.

Topics in the full lesson
  • Introduction to Mapped and Conditional Types
  • The keyof Operator
  • The typeof Operator
  • Mapped Types
  • Conditional Types
  • Distributive Conditional Types
  • Built-in Utility Types
  • Advanced Examples
  • Best Practices
  • Exercises

Try the free interview questions

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

TheoryMedium

`typeof` at the Type Level

Question

How does typeof work in a type context? Show how it differs from runtime typeof and the common use cases.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Conditional Type Use Cases

Question

What are the canonical use cases for conditional types? Show four real patterns and when they're the right tool.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Conditional Types: `T extends X ? Y : Z`

Question

What is a conditional type in TypeScript? Show the T extends X ? Y : Z syntax and explain when to reach for one.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryHard

Distributive Conditional Types

Question

What are distributive conditional types in TypeScript? Walk through the mechanism step by step, then show the bracket-wrap trick that suppresses distribution.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryHard

The `infer` Keyword

Question

What does the infer keyword do? Show how it extracts types from positions inside conditional types.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Conditional 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

Continue in this section