typescript / beginner
Snippet
TypeScript Tuples
Tuples allow you to define an array with a fixed number of elements where each element has a specific, known type.
snippet.ts
1
2
type Coordinate = [number, number];const start: Coordinate = [10, 20];
Breakdown
1
type Coordinate = [number, number]
Creates a type alias for an array that must contain exactly two numbers.
2
[10, 20]
Assigns an array that matches the specified length and types.