Type Annotations
Learn how to use type annotations to guide TypeScript when inference isn't enough so your code stays safe, predictable, and intentional.
TypeScript’s inference is smart—but it’s not a mind reader. It knows let score = 100 is a number. Great. But what if there’s no value yet? What if it changes—or never shows up at all?
That’s when we stop relying on inference and start being intentional. We tell TypeScript what the type should be. This is the moment where inference ends and type annotations begin.
How to write a type annotation
Here’s the syntax. It’s simple but powerful: