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:
tsTry
export lethelloWorld = "hi";
Will generate an index.js
file like this:
tsTry
export let helloWorld = "hi";
With a corresponding helloWorld.d.ts
:
tsTry
export declare let helloWorld: string;
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.