

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Tuples
incomplete
2: Readonly
incomplete
3: Tuples vs. Objects
incomplete
4: Destructuring Tuples
incomplete
5: Named Tuples
incomplete
6: Optional Elements in Tuples
incomplete
7: Tuple Rest Elements
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Tuples in TypeScript are (guh) still arrays under the hood, so counterintuitively you can still push to them and pop from them. This is a bit of a gotcha, tuples in most languages are fixed length.
Getting out-immutable'd by Python is a sad state of affairs.
const nameAndAge: [string, number] = ["Martha Jones", 24];
nameAndAge.push("Donna Noble");
So you still need to be careful about underlying array length... that is, unless you use readonly tuples, which is really the only way I use tuples.
const nameAndAge: readonly [string, number] = ["Martha Jones", 24];
// Error: Property 'push' does not exist on type 'readonly [string, number]'.
nameAndAge.push("Donna Noble");
Much better! I use readonly any time I possibly can, it's kinda like using const over let whenever possible. However, keep in mind that readonly is TypeScript specific, which means it's enforced at compile time, but not at runtime (like const is).
The Ticket tuple now has a 4th property: "resolved", a boolean indicating whether the ticket has been resolved.
Fix the resolveTicket function. It takes as input a Ticket tuple and returns a newly resolved Ticket.
Ensure the resolveTicket function returns a Ticket, not just an array.