April 2026
Intermediate to advanced
432 pages
8h 21m
English
Throughout this book, you’ve been using relatively simple type annotations to specify what types your variables and functions should have, or you’ve allowed TypeScript to infer types on its own. But sometimes you need to lie to TypeScript. In this chapter, you will learn different ways to communicate with the compiler with annotations and assertions: techniques that allow you to affect type inference and force TypeScript to treat values as certain types.
There’s a difference in TypeScript between annotating variables and annotating values. The way they conflict can be confusing, ...
Read now
Unlock full access