the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

Editing TS1046:

All diagnostics and fixes are authored in markdown. Propose any changes by editing the markdown. Additional fixes can be added. A preview of the rendered diagnostic will update when changes are made.

Once all proposed changes are made, the Propose button will submit the information and confirm raising the PR.

TS1046

Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

Declaration files (.d.ts) cannot contain implementation code, they can only describe the shape of a module. Therefore the following will cause this error:

const a = 1;

Fix: Add 'declare' or 'export' to each top-level declaration.

Ensure each top-level declaration uses the declare or export keyword:

declare const a: 1;