
Lesson 02 · 9 min
Inference: when you don't need to write the type
The compiler already knows the type. An annotation is needed when it can't guess.
The most common beginner mistake is putting : string on every variable. TS infers the type from the value anyway. That's type inference: let count = 0 is already a number. Write annotations at the boundaries: function arguments, values returned by a public API, an empty initial state.
Sign in to continue
The rest of this lesson opens after sign up
The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.