TSConfig

declaration

Generate .d.ts files for every TypeScript or JavaScript file inside your project. These .d.ts files are type definition files which describe the external API of your module. With .d.ts files, tools like TypeScript can provide intellisense and accurate types for un-typed code.

When declaration is set to true, running the compiler with this TypeScript code:

ts
export let helloWorld = "hi";
Try

Will generate an index.js file like this:

ts
export let helloWorld = "hi";
 
Try

With a corresponding helloWorld.d.ts:

ts
export declare let helloWorld: string;
 
Try

When working with .d.ts files for JavaScript files you may want to use emitDeclarationOnly or use outDir to ensure that the JavaScript files are not overwritten.