TS1046

error TS1046: Top-level declarations in .d.ts files must start with either a ‘declare’ or ‘export’ modifier.

Broken Code ❌

index.d.ts
1
const MAGIC_NUMBER = 1337;

Fixed Code ✔️

If you want to export a constant from a definition file (d.ts), then you have to use the export modifier:

index.d.ts
1
export const MAGIC_NUMBER = 1337;