Overview - Type annotation on variables
What is it?
Type annotation on variables means telling the computer what kind of value a variable will hold. Instead of guessing, you explicitly say if a variable is a number, text, or something else. This helps catch mistakes early and makes your code clearer. It is like labeling boxes so you know what is inside without opening them.
Why it matters
Without type annotations, the computer might misunderstand what you want to do, causing errors that are hard to find. Type annotations help prevent bugs by checking your work before running the program. This saves time and frustration, especially in big projects where many people work together. It also makes your code easier to read and maintain.
Where it fits
Before learning type annotations, you should know basic variables and data types in TypeScript or JavaScript. After this, you can learn about functions with typed parameters and return types, interfaces, and classes. Type annotations are a foundation for writing safe and clear TypeScript code.