A `.d.ts` file contains only type declarations, no runtime code. It's used to describe the shape of plain JavaScript libraries, or to add global types to a project.
ts
// globals.d.ts
declare global {
interface Window {
ethereum?: { request: (args: { method: string }) => Promise<unknown> };
}
}
export {};Module augmentation lets you add to an existing module's types without modifying its source, e.g. extending a third-party library's interface with an extra field your app relies on. Many npm packages ship their own `.d.ts` (or point to `@types/<package>` on DefinitelyTyped) so consumers get type checking without the library itself being written in TypeScript.