Skip to main content
Frontend tutorial

1.1. Describe a shipment with types

Three shipments, and nobody can tell which one is urgent. Let's give each one a priority.

In /shipments.ts, the Shipment interface describes what every record holds. Add the new field in place of the TODO:

priority: 'standard' | 'express';

Give S-101 priority: 'express' and the other two priority: 'standard'. Then show it in /App.tsx, in place of the TODO in the list item:

<span> · {shipment.priority}</span>

One thing to know before you try: like Vite, this preview removes the types without checking them, and the editor here doesn't check them either. VS Code and pnpm build do, and you'll see that in 2.1.

Need a hint?
  • The field is required, so every record in the array needs a priority.
  • Inside the list item, shipment is the current record: {shipment.priority}.

When S-101 shows express, misspell it as 'expres'. The preview shows the typo without complaint.

Work locally

You need Node.js 24, pnpm and Git (how to set them up). Clone this step’s starting code:

git clone --depth 1 \
--branch lesson-01-01-shipment-shape-start-v6 \
https://github.com/adam-zielonka/frontend-tutorial.git \
01-01-shipment-shape
cd 01-01-shipment-shape
pnpm install --frozen-lockfile
pnpm dev

To keep your own commits: git switch -c my-work.

Browse the source on GitHub (opens in a new tab)

Bring your browser edits

Choose Download my files in the ⋯ menu. It saves the lesson’s files as JSON. Stop the local server with Ctrl+C, copy the download into the project folder and run:

node import-draft.mjs ./01-01-shipment-shape-my-files.json
pnpm dev

The import replaces the project’s exercise files, so commit or back up local edits first.

Loading this step’s code…
Starting the live preview…