Primitive Types
A free lesson from Swipe Coding · TypeScript, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
TypeScript's most basic types map directly onto JavaScript's primitive values: string for text, number for all numbers, and boolean for true/false. Each one is written in lowercase, right after a variable's name.
let username: string = "amara"; let score: number = 87; let isActive: boolean = true;
number covers every numeric value in TypeScript — whole numbers, decimals, negatives — there's no separate int, float, or double the way there is in some other languages. JavaScript only has one numeric type under the hood, and TypeScript matches that.
let price: number = 19.99; let temperature: number = -4; let quantity: number = 12;
string covers any text, written with single quotes, double quotes, or backticks for template literals — TypeScript doesn't care which quoting style you use, only that the value is text.
let city: string = 'Nairobi';
let greeting: string = `Hello, ${city}!`;let isActive: ____ = true; is the correct annotation for a variable that only ever holds true or false.
Which type would you use to annotate a variable that holds the value 3.14?
TypeScript has separate int and float types for whole numbers and decimals.
Keep your streak going in Swipe Coding
Swipe through every level of TypeScript on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →