This course is about writing a type once and deriving the rest.
The Riverside Kids’ Football League runs three volunteer scripts. Each one has its own copy of the league’s types, and one copy says the age group is a number. The type check passes anyway, since each script is checked only against its own copy:
$ npm run check
> [email protected] check
> tsc --noEmit
But when you run the league table script, node league/league-table.ts, it finds none of the league’s two U10 teams:
U10 table: 0 teams
The league keeps its data behind a JSON API. In this course, you’ll write one typed client for it, a module that every script imports from. With your client, the same command finds both teams:
U10 table: 2 teams
Riverside Lions
Mill Lane Otters
When a type changes in the client, the checker points at every script you need to update.
What You’ll Learn
By the end of this course, you’ll be able to:
- Type classes and modules
- Keep to syntax that can be erased
- Write generic functions and types that keep the relation between inputs and outputs
- Derive types from one source with
keyof,typeofand utility types
You’ll finish by building the league’s API client, then explaining it to the course’s AI mentor.
Before You Start
You should know type annotations, object types, type aliases, literal unions, type guards, ES modules, and JavaScript classes. You should also be able to read a generic type that someone else wrote, like Promise<T>.
You need a current Node.js release with long-term support (LTS) and an editor that knows TypeScript. This course’s code was run with this version:
$ node --version
v26.13.1
How the Course Works
The course’s Sample Code (.zip), linked below this video, is the Riverside project: a strict TypeScript setup, a check script, npm run check, and a stand-in for the league’s API. You’ll set it up in the first lesson, and the project lesson adds the league’s three old scripts.
Coding exercises run in your browser, not in your local project. They sit beside text lessons, short videos, and a quiz. Next up is Typing a Class and Its Methods, on the class behind the league table script.