Primitive Types in TypeScript

From the TypeScript cheat sheet · Basic Types · verified Jul 2026

Primitive Types

TypeScript basic primitive types and type annotations

typescript
// Basic types
let name: string = "John"
let age: number = 30
let isActive: boolean = true
let value: any = "anything"
let id: symbol = Symbol("id")
let big: bigint = 100n

// Arrays
let numbers: number[] = [1, 2, 3]
let names: Array<string> = ["Alice", "Bob"]

// Tuple
let tuple: [string, number] = ["hello", 10]

// Enum
enum Color { Red, Green, Blue }
let color: Color = Color.Green
💡 Use unknown instead of any when possible
📌 const assertions create readonly literal types
✅ Enable strictNullChecks for better null safety

More TypeScript tasks

Back to the full TypeScript cheat sheet