Project: The Lantern Street Theatre's Ticketing

Door-check and the ticketing slice were practice. Every piece you’ve typed in this course, from the first tsconfig.json to the last escape hatch, is something Tobias Okonkwo’s ticketing pages need. Mei Chen’s box office sells every seat of the season through those pages, and they’re still mostly JavaScript, with strict off.

In this project, you’ll migrate them to strict TypeScript in six steps, each ending with the pages working and npm run check passing. Four steps are graded exercises, and you do the other two in the project on your own. Keep this brief open while you work, because each step starts here. First, run the project as Tobias left it.

Run the Pages as Tobias Left Them

Before you change a line, get the project installed, checked, and running, so you can tell when a step breaks something. The project is in the course’s sample code download, the one linked on the course page and in the course overview and summary lessons. If you haven’t downloaded it yet, do it now and extract it. Inside, next to door-check and ticketing, is a third folder, ticketing-pages.

ticketing-pages is the Vite project behind the theater’s booking page. Its index.html holds the show list, the seat map, the basket, and the checkout, and a customer moves through them in that order.

The modules in its src/ folder are already partway through the migration:

  • prices.ts, returns-waitlist.ts, and ticket-types.ts are the slice you migrated. Tobias copied them back in as you left them and exported TicketType so the other modules can use it.
  • booking.js is Tobias’s booking module. A booking holds a reference, a name, an email, a performance, and seats with their ticket types. He started typing it with JSDoc comments and stopped halfway.
  • seat-map.js draws a button for each of the 120 seats and handles their clicks. A click reads the ticket-type select and passes the seat and its type on. It labels each seat with @lantern/seat-labels, the helper in packages/seat-labels/ that you declared in door-check.
  • basket.js keeps the performance and seats a customer picks and works out their total.
  • checkout.ts takes the customer’s name and email, makes the booking, and shows its reference with a QR code, the square barcode Rosa Delgado’s ushers scan at the door. It makes the code with the qrcode package. An AI assistant wrote this module in TypeScript.
  • main.js holds the season’s shows, fills the show list and the basket, and starts the page.

Tobias’s tsconfig.json is close to the slice’s before you changed it:

Language: JSON Filename: tsconfig.json
{
  "include": ["src"],
  "compilerOptions": {
    "target": "esnext",
    "lib": ["esnext", "dom"],
    "module": "esnext",
    "moduleResolution": "bundler",
    "allowJs": true,
    "allowImportingTsExtensions": true,
    "strict": false,
    "noEmit": true,
    "verbatimModuleSyntax": true,
    "erasableSyntaxOnly": true
  }
}

Compare it with the slice’s configuration. "allowJs" lets the .js files into the project. "allowImportingTsExtensions" is there because several modules, from the slice’s files to booking.js, import TypeScript files by their real names, such as ./prices.ts. There’s no "checkJs", so tsc reports no errors in the JavaScript files, and "strict": false turns off the checks you’ve had on everywhere else in this course.

Open a terminal in the folder, install its packages, and run the check:

Language: Shell
$ cd ticketing-pages
$ npm install

added 46 packages, and audited 48 packages in 3s
...
$ npm run check

> [email protected] check
> tsc --noEmit -p tsconfig.json

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.