Declaration Files in TypeScript

From the TypeScript cheat sheet · Modules & Namespaces · verified Jul 2026

Declaration Files

Type declarations for JavaScript libraries and modules

typescript
// Ambient declarations (*.d.ts)
declare module "untyped-module" {
  export function doSomething(): void
  export const value: string
}

// Global declarations
declare const VERSION: string
declare function analyticsTrack(event: string): void

// Module declarations
declare module "*.css" {
  const content: { [className: string]: string }
  export default content
}

declare module "*.svg" {
  const content: React.FC<React.SVGProps<SVGSVGElement>>
  export default content
}
💡 Use @types packages for library types
📌 .d.ts files contain only type declarations
✅ Declare modules for assets and untyped packages

Continue with TypeScript

Save the full cheat sheet or work through every related task.

More TypeScript tasks

Back to the full TypeScript cheat sheet