We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Readonly

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).

Assignment

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.