Practical TypeScript
55‑70 hours · 18 modules · 76 lessons · Project: Typed API client
M1 · 4 lessonsTypeScript's Own Tools
- 1.1
tsc:--noEmit,--watch, and reading its output - 1.2Your editor as a TypeScript tool: hover, go to definition, rename, quick fixes
- 1.3Reading long, nested type errors
- 1.4Strict flags beyond
strict: what each one catches and which to turn on - Project stepStart the API client: strict flags, plus
checkandwatchscripts.
M2 · 5 lessonsHarder Narrowing Cases
- 2.1Exhaustiveness checking with
never - 2.2Type guards (
x is T), and when TypeScript infers them for you - 2.3Assertion functions (
asserts x is T) - 2.4
instanceofand class-based narrowing - 2.5Type assertions (
as): when they're justified and why they're risky - Project stepModel the client's commands as a union and handle every case exhaustively.
M3 · 9 lessonsType Operators
- 3.1Intersection types (
&): combining shapes, and how they differ fromextends - 3.2The wide types:
unknown,object, and{} - 3.3
keyof - 3.4The
typeoftype operator - 3.5Indexed access types (
T["key"]) - 3.6
as constand types derived from data - 3.7The
satisfiesoperator - 3.8Index signatures and
noUncheckedIndexedAccess - 3.9Why
Object.keysreturnsstring[] - Project stepDerive command names and option types from one
as constconfig checked withsatisfies.
M4 · 4 lessonsGenerics in Practice
- 4.1Constraints with
extends - 4.2The
K extends keyof Tpattern - 4.3Default type parameters
- 4.4Generic classes and containers
- Project stepWrite a generic
request<T>()helper and a typed cacheCache<K, V>.
M5 · 4 lessonsBuilt-in Utility Types
- 5.1
Partial,Required,Readonly; a missing property vsundefined - 5.2
Pick,Omit,Record - 5.3
Exclude,Extract,NonNullable - 5.4
ReturnType,Parameters,Awaited - Project stepBuild create, update, and summary types from one base type.
M6 · 3 lessonsImmutability and Tuples
- 6.1
readonlyarrays andReadonlyArray<T> - 6.2Named, optional, and rest elements in tuples
- 6.3Updating without mutating:
toSorted,with, andstructuredClone - Project stepMake settings and cache entries read-only; return new objects instead of changing old ones.
M7 · 5 lessonsDesigning with Types
- 7.1Making impossible states impossible
- 7.2Modeling loading, success, and error states
- 7.3Branded types for IDs and units
- 7.4Parse, don't validate
- 7.5When not to add more types
- Project stepModel each request as idle, loading, success, or error, and brand the IDs.
M8 · 4 lessonsAdvanced Functions
- 8.1Function overloads
- 8.2Typing
this, and how methods lose their context - 8.3Generic callbacks and higher-order functions
- 8.4Iterables and generators:
function*andGenerator<T> - Project stepAdd an overloaded
get()and a generator that pages through results.
M9 · 4 lessonsClasses in Depth
- 9.1
implementsandabstract - 9.2Getters, setters, and
staticmembers - 9.3
protected, and why modern code avoids parameter properties - 9.4Composition vs inheritance
- Project stepHide HTTP behind an interface with two classes: a real client and a fake one.
M10 · 5 lessonsErrors and Concurrent Code
- 10.1Custom error classes and
cause - 10.2The Result pattern instead of exceptions
- 10.3
Promise.all,allSettled,race,any, and their types - 10.4Timeouts and cancellation with
AbortController - 10.5Async iteration with
for await - Project stepReturn Results instead of throwing; add timeouts, cancellation, and parallel requests.
M11 · 5 lessonsData at App Boundaries
- 11.1Why types don't protect you at runtime
- 11.2Writing validators by hand with type guards
- 11.3Typing and validating API responses
- 11.4Deriving types from validators: the idea behind schema libraries
- 11.5Typing and validating configuration and environment variables
- Project stepValidate every API response with hand-written guards before it enters the app.
M12 · 4 lessonsStandard Library Essentials
- 12.1Regular expressions: the basics, and typed match results
- 12.2
Intl: formatting numbers, currencies, and dates for any language - 12.3Dates and times:
Datepitfalls and Temporal - 12.4The rarer primitives:
bigintandsymbol - Project stepFormat prices, dates, and numbers for the user's locale; parse fields with regex.
M13 · 5 lessonsHow TypeScript Finds and Runs Code
- 13.1
tsconfig.jsonin detail:target,module,rootDir,outDir,lib,types - 13.2Module resolution:
nodenextorbundler, and how to choose - 13.3ESM and CommonJS: what you'll meet in other people's code
- 13.4Three ways to run TypeScript, and when to use each
- 13.5Organizing a project: folders, barrel files, and a module's public API
- Project stepReorganize the client into folders with a clear public API and build it with
tsc.
M14 · 4 lessonsUntyped Code
- 14.1Libraries without types:
declare module - 14.2Ambient declarations, global types, and
.d.tsfiles - 14.3Namespaces: recognizing an older pattern
- 14.4OptionalIf you end up in a JavaScript project:
allowJs,checkJs, and JSDoc - Project stepAdd a small untyped helper package and describe it with your own
.d.tsfile.
M15 · 3 lessonsReviewing TypeScript Code
- 15.1Type-safety smells:
any,as,!,@ts-ignore, and aswitchthat isn't exhaustive - 15.2Reading unfamiliar TypeScript
- 15.3Reviewing AI-generated TypeScript with the same checklist
- Project stepReview your own client with the smell checklist and fix what you find.
M16 · 3 lessonsTesting Typed Code
- 16.1Structuring tests with
node:test; typed fixtures and test data builders - 16.2Testing asynchronous code
- 16.3Typed test doubles without a framework
- Project stepCover the client with tests, using the fake HTTP class from Module 9.
M17 · 4 lessonsPopular Libraries, Step Two
- 17.1
zod: schemas that become types, compared with your hand-written validators - 17.2
axios: typed HTTP requests, and whyget<User>()is a promise, not a check - 17.3
ts-pattern: exhaustive pattern matching over unions - 17.4
vitest: moving yournode:testsuite to a popular test framework - Project stepReplace hand-written guards with Zod, try axios, and move the tests to Vitest.
M18 · 1 lessonFinal Project
- 18.1A typed command-line API client: validated responses (by hand, then with Zod), a disk cache, Result-based errors, and full tests
- Project stepShip the client: a README, a clean
checkrun, and tests for every core feature.