Caffeinated Coder
Book an appointment
Lesson 12 · Advanced and in practice

Mapped and conditional types

In TypeScript you can build a new type out of an old one. Follow one seven-line file as keyof lists User's keys, a mapped type loops over them, T[K] looks up each key's type, and a conditional type turns numbers into strings. tsc computes Form = { id: string; name: string; admin: boolean }, then uses it to catch a wrong value.

12 min9 steps5 questionsAdvanced
Fig 12 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.