You do not have to annotate everything.
Direct answer
Type inference means TypeScript works out types from your code. let n = 5 is inferred as number. Let inference do the work for local variables and return values, and add annotations on function parameters, exported APIs and places where the inferred type is too wide.
Examples
let count = 5; // number
const name = "Ada"; // "Ada" (literal)
const nums = [1, 2, 3]; // number[]
function add(a: number, b: number) {
return a + b; // return type inferred as number
}
When to annotate
const items: string[] = []; // empty array needs help
function greet(user: User): string { // parameters need types
return `Hi ${user.name}`;
}
Tip
Hover over a variable in your editor to see what TypeScript inferred.
Where Teyro fits
Teyro's TypeScript for Beginners course turns this into short lessons you can play in a few minutes a day. It has 20 lessons, and you can start free.
The bottom line
Annotate boundaries, infer the middle.


