Caffeinated Coder
Book an appointment
Lesson 13 · Advanced and in practice

Modules and declaration files

A TypeScript file with a top-level import or export is a module, and modules share code by exporting and importing names. Follow one small library, math.ts, as tsc --declaration splits it into two files: math.js, the code with the types removed, and math.d.ts, the types with the code removed. Then watch tsc check another module against the .d.ts file alone, catch a bad call, and Node.js run the result without ever loading the types.

11 min9 steps5 questionsAdvanced
Fig 13 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.