.d.ts files describe JavaScript libraries without implementation. declare module 'legacy-lib' adds types for untyped packages.
DefinitelyTyped
Most npm packages ship types via @types/package on DefinitelyTyped. When missing, add a local types/package/index.d.ts and reference it from tsconfig typeRoots.
Self-check
- What is the difference between
.tsand.d.tsfiles?
Ambient declarations describe global variables injected by build tools or legacy script tags without importing modules.
Practice: Apply declarations-ambient in the playground, then explain declarations ambient in one sentence without looking at notes.