TypeScript - Tuples

tuple is a typed array with a pre-defined length and types for each index

To define a tuple, specify the type of each element in the array:

let ourTuple: [number, boolean, string];
ourTuple = [5, false, 'Typescript'];

Typescript will throw error if the data type is not correct

You can still add more value into a tuple

let ourTuple: [number, boolean, string];
ourTuple = [5, false, 'Typescript'];
// We have no type safety in our tuple for indexes 3+
ourTuple.push('Anything here');
console.log(ourTuple);
Output
[5, false, 'Typescript', 'Anything here']

So it is a good practice to add readonly to our tuple to prevent it from adding more values