Caffeinated Coder
Book an appointment
Lesson 03 · Typing JavaScript

Type inference

You do not have to write a type on every variable. Follow a five-line file with no types written at all as tsc, the TypeScript checker, works out each one from its starting value: count and total are numbers, label is a string, and the const unit gets the exact type "kg". Then watch the type it inferred catch count = "three" before the program runs.

9 min9 steps5 questionsBeginner
Fig 3 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.