Modules and Declaration Files
Split code into files with import and export, learn how the compiler finds files, read and write .d.ts files, type third-party code and check plain JavaScript.
Real projects are many files, not one. This phase is about what happens between files: how import and export work in TypeScript, how the compiler decides which file an import points to (module resolution), and how it learns the types of code that is not written in TypeScript at all.
You'll meet declaration files (.d.ts), the files that hold only types. They are how npm packages ship their types, how @types/* packages type old JavaScript libraries, and how you describe things that exist at runtime but that TypeScript did not create (a script tag that adds window.analytics, an environment variable the bundler replaces). You'll also learn to extend existing types (declare global, module augmentation) and to type-check plain .js files with JSDoc comments.
The live editor on this site is one file, so imports between files can't run there. Where an example needs several files, the page shows real files from a small project built for this course and the real output of tsc (TypeScript 7.0.2) run on it. Everything that fits in one file (declare, declare global, namespaces, JSDoc) is a live example you can edit.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.