TypeScript: Advanced
Types that compute
Past the point where the compiler works it out for you, TypeScript is a small language whose values are types. This is that language — generics, conditionals, the loop over keys — and then the two mechanical systems underneath it: what a declaration file claims, and which file an import actually loads.
- Modules
- 7
- Drills
- 7
- Build steps
- 5
- Time
- ~4h
Walk out able to
Write the utility type your codebase needs, declare a dependency nobody typed, and say which file an import lands on before running anything.
What you work through
Generics that infer
Constraints, keyof, and what T was worked out to be.
Branching and mapping
Conditional types, the loop over keys, spelled from memory.
The utility types
Pick, Omit, Exclude — derived, then written yourself.
Declarations and lookup
A .d.ts for an untyped package, and where imports land.
The pitch
What you practise, and what you leave with
A types folder for a dependency that ships none: a hand-written .d.ts, a tsconfig that finds it, and the evidence the compiler agreed.
You will practise
- Generic inference and constraints
- Conditional types, infer, distribution
- Mapped types, and the syntax from memory
- Declaration files and module resolution
Afterwards you can
- Evaluate a conditional type over a union
- Write the utility type your codebase needs
- Declare a package nobody typed
- Say which file an import resolves to
Modules
7 modules, 30 items
Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.
- 1
Make a signature carry it
~33 minRead a generic signature and say what the compiler worked each type argument out to be.
- LessonWhy the type system computes4 min
- LessonRead a signature by substituting6 min
- LessonA constraint is a floor, not a shape6 min
- LessonA default is not a constraint5 min
- DrillSay what T was inferred as12 min
- 2
Types that ask a question
~32 minEvaluate a conditional type over a union, and pull a type out of a position with infer.
- LessonA type with a branch in it7 min
- LessonPull a type out with infer6 min
- LessonA naked parameter distributes7 min
- DrillEvaluate a conditional type12 min
- 3
Rewrite every key
~31 minWrite a mapped type over keyof T, move its modifiers, and drop keys by remapping them.
- LessonThe loop over keyof T6 min
- LessonAdd and remove the modifiers6 min
- LessonRename a key, or drop it7 min
- DrillApply a mapped type by hand12 min
- 4
Write it from memory
~10 minSpell a generic, a conditional and a mapped type from memory, and spot the broken one.
- DrillSpell the type-level syntax10 min
- 5
The utility types, derived
~38 minName the utility that produces a given result, write one of your own, and say when not to.
- LessonA library you could have written7 min
- LessonThe type you did not write5 min
- DrillName the utility type10 min
- Build stepWrite a utility type of your own16 min
- 6
Type a library nobody typed
~44 minWrite a .d.ts for an untyped package, apply the rules, and augment a module you don't own.
- LessonWhen a package ships no types6 min
- LessonThe mistakes that keep happening6 min
- LessonAdd to a module you do not own6 min
- DrillDeclare the module correctly11 min
- Build stepWrite a .d.ts and make it bite15 min
- 7
Follow an import to a file
~1hSay which file a specifier loads, what each option decides, and why a lookup failed.
- LessonHow an import finds a file6 min
- LessonWhat decides a file's format6 min
- LessonThe manifest is a lookup table6 min
- DrillResolve a specifier to a file12 min
- Build stepRead a resolution failure12 min
- Build stepDeclare a dependency nobody typed13 min
- Build stepMake the compiler find it9 min
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
The type system is a language. Write it.
The first item is free. ~4h of focused work, at your own pace.
Advanced~4h7 modules