TypeScript Tutorial #3: Basic Types
In the previous tutorial, we installed TypeScript and wrote our first program. Now let’s learn the type system — the core feature that makes TypeScript useful. By the end of this tutorial, you will know every basic type in TypeScript and when to use each one. Type Annotations A type annotation tells TypeScript what type a variable should be. You add it after the variable name with a colon: let name: string = "Alex"; let age: number = 25; let isActive: boolean = true; The : string, : number, and : boolean are type annotations. If you try to assign the wrong type, TypeScript gives an error: ...