TypeScript tutorialLesson 5Free preview
TS Explicit & Inference
This lesson is part of TypeScript · All levels
Summary
Type inference is the ability of TypeScript to guess the type of a value without explicit annotation. Explicit annotation is used when the type needs to be known beforehand or ambiguous initial values such as null. The combination of the two makes the code compact yet secure.
Key points
- Inference guesses the type of the initial value
- The explicit annotation is written with colon
- The number variable must not be filled with the value of the string
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.