the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

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;