Finding Where Types Lie

Door-check’s npm run check now runs tsc and ESLint’s type-aware rules. When both pass, it’s tempting to treat the code as reviewed. But both tools trust what the code says about its own types, and code can tell them to stop checking.

In this lesson, you’ll review an AI assistant’s change for the ushers and decide whether a passing check means it’s ready. You’ll replace the lines where code tells the checker to stop checking, and leave with a list of places to look in code you didn’t write. Start as you’d start any review: add the change and run the check.

Review the Assistant’s Seat Map

A change that passes the check still needs reading. Rosa Delgado wants door-check to show the free seats in each row, so ushers can seat someone who buys a returned ticket at the door. Mei Chen exports the night’s seat map from the box office as JSON. Save her file as public/seat-map.json in door-check. Vite serves public/ from the site’s root, so the page can fetch /seat-map.json:

Language: JSON Filename: public/seat-map.json
{
  "performance": "2026-03-14 19:30",
  "rows": [
    { "row": "A", "booked": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] },
    { "row": "C", "booked": [7, 8] },
    { "row": "F", "booked": [1, 2, 3, 4] },
    { "row": "H", "booked": [4, 5, 6] }
  ]
}

Each row lists its booked seats. For the result, add a heading and a list below <ul id="door-list"></ul> in index.html:

Language: HTML Filename: index.html
    <h2>Free seats</h2>
    <ul id="free-seats"></ul>

Tobias Okonkwo asked an AI assistant for the feature. Create src/seat-map.ts with its code, starting with its types and two functions:

Language: TypeScript Filename: src/seat-map.ts
 1export type SeatRow = {
 2  letter: string;
 3  booked: number[];
 4};
 5
 6export type SeatMap = {
 7  rows: SeatRow[];
 8};
 9
10export async function loadSeatMap(): Promise<SeatMap> {
11  const response = await fetch("/seat-map.json");
12  return (await response.json()) as SeatMap;
13}
14
15export function freeSeats(map: SeatMap, letter: string): number {
16  const row = map.rows.find((entry) => entry.letter === letter)!;
17  return 12 - row.booked.length;
18}

freeSeats() finds a row by its letter and subtracts the number of booked seats from the row’s total of 12. The rest of the file loads the map and adds one line per row, A to J:

Language: TypeScript Filename: src/seat-map.ts
20const seatMap = await loadSeatMap();
21const freeList = document.querySelector("#free-seats");
22
23for (const letter of "ABCDEFGHIJ") {
24  const item = document.createElement("li");
25  const free = freeSeats(seatMap, letter);
26  item.textContent = `Row ${letter}: ${free} free`;
27  freeList?.append(item);
28}

To run the file, import it in src/main.ts, below import "./check-in.ts";:

Language: TypeScript Filename: src/main.ts
import "./seat-map.ts";

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.