November 2018
Beginner
502 pages
10h 22m
English
Tuples have had a few enhancements in TypeScript 3, so that they can be used with the popular rest and spread JavaScript syntax. Before we get into the specific enhancements, we'll go through what tuples are, along with what the rest and spread syntax is. A tuple is like an array but the number of elements are fixed. It's a simple way to structure data and use some type safety.
Let's have a play with tuples:
let product: [string, number];
We've initialized a product variable to a tuple type with two elements. The first element is a string and the second a number.
Read now
Unlock full access