Tuples & Readonly in TypeScript
From the TypeScript cheat sheet · Basic Types · verified Jul 2026
Tuples & Readonly
Fixed-length typed arrays and immutable modifiers
typescript
// Tuple — fixed length, typed positions
const coord: [number, number] = [10, 20];
const entry: [string, number] = ["age", 30];
// Readonly — prevents mutation
const point: readonly [number, number] = [10, 20];
const names: readonly string[] = ["Alice", "Bob"];💡 Tuples are arrays with fixed length and typed positions — great for return values
⚡ as const makes everything deeply readonly AND narrows to literal types
📌 readonly on arrays prevents push/pop/splice — the reference can still be reassigned
🟢 Named tuples (labels) improve readability but have no runtime effect
tuplereadonlyas-const