Skip to content
AgileLogics
4 min read

Declaration Files

Prerequisites: Working with third-party JavaScript

A .d.ts file describes a JavaScript library's types without containing any actual implementation code — what @types packages are made of, and what you'd write yourself for an untyped package with no @types package available.

// my-library.d.ts
declare module "my-library" {
    export function doSomething(value: string): number;
}

This tells TypeScript "trust me, this JavaScript module has this shape" — it's a promise you're making to the compiler, not something it verifies against the actual JavaScript.