You can use the tuple()
function in tuple.ts
to infer tuple types in TypeScript and cut down on the need to repeat yourself. Without tuple()
, declaring a constant of a tuple type looks like this:
const daysOfTheWeek: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] =
["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
You can't do this:
const daysOfTheWeek = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];