TypeScript checks your code before it runs. Data from a file or an API arrives at run time, so the checker never sees it. In this course, you’ll check that data yourself at the boundary, where it enters your program.
The Millbrook Birders, a birdwatching club, log their sightings in a phone app that exports JSON. The club’s import script asks a species API about each bird and adds new ones to the year list, every species the club has seen this year. Its type check passes, but when it runs on May’s export, undefined goes on the year list where a bird’s name should be:
$ node --env-file=.env imports.ts exports/may.json
Year list: 4 species
- Atlantic Puffin
- undefined
- Red Kite
- Little Egret
In this course, you’ll rewrite that import. On the same export, your version says why it turns sightings away and keeps undefined off the list:
$ node --env-file=.env imports.ts exports/may.json
Rejected: Entry 2, species: Invalid input: expected string, received undefined
Rejected: Entry 4, species: Invalid input: expected string, received undefined
Not added: Unknown species: Eurasian Curlw
Year list: 3 species
- Atlantic Puffin
- Red Kite
- Little Egret
What You’ll Learn
By the end of this course, you’ll be able to:
- Tell a type assertion that’s justified from one that hides a bug
- Type async code
- Treat data from files and APIs as
unknown - Check it once at the boundary with type guards or a schema
You’ll finish by rewriting the club’s import, then explaining it to the course’s AI mentor.
Before You Start
You should know type annotations, union types and narrowing. You should also know why the type unknown is safer than the type any, and how to await a fetch() call.
You need a current Node.js release with long-term support (LTS) and an editor with TypeScript support. Node.js runs TypeScript files without checking their types. To see which version you have, run node --version:
$ node --version
v26.13.1
How the Course Works
In the first lesson, you’ll download the course’s Sample Code (.zip): a Millbrook project with TypeScript, a strict setup, a check script, and a stand-in species API. The lessons build on it, and the project lesson adds the club’s old import.
The course has text lessons, short videos, and coding exercises in your browser, and it ends with a chat with the mentor, a quiz, and a summary. In the next lesson, Asserting a Type With as, you’ll see how that undefined got past the checker.