TypeScript Types
Readonly tuples — positional read-only view
A readonly tuple combines a positional element contract with a restriction on mutation through that typed reference. It can still be backed by a mutable tuple held by another part of the program. Readonly does not create a copy or enforce deep immutability. Use it when consumers should read a fixed-format result without changing it. Example output: "7". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
type Pair = readonly [string, number];Working Example
Example Snippettypescript
const point: readonly [number, number] = [3, 4];console.log(point[0] + point[1]);