Declaration Files
Question
What is a .d.ts file?
Hint
.d.ts files describe the types of JS libraries for TS consumers.
Explanation
A .d.ts (declaration) file contains TypeScript type declarations without any implementation code. It describes the types of an existing JavaScript library, allowing TypeScript projects to use the library with type checking. The declare keyword is used for ambient declarations. Example: declare module "my-lib" { export function foo(x: number): string; }. When you npm install a package with types, you are installing .d.ts files (either bundled or from @types/* packages via DefinitelyTyped). .d.ts files have no runtime impact.
Related Resources
Related Lessons
- Modules
Learn modules.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.