Primitive Types: string, number, boolean
Annotate variables with TypeScript's three core primitives.
Welcome
TypeScript's three core primitive types are string, number, and boolean. In this lesson you'll learn how to annotate variables with these types.
Annotating Variables
Add a type annotation after the variable name with a colon. TypeScript will enforce the type for the lifetime of the variable.
let username: string = 'Alice';
let score: number = 100;
let isLoggedIn: boolean = true;All lessons in this course
- Primitive Types: string, number, boolean
- The any Type and Why to Avoid It
- unknown vs any: The Safer Choice
- null, undefined, and Strict Null Checks