the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

Editing TS1039:

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.

TS1039

Initializers are not allowed in ambient contexts.

Initializers represent functional code and are invalid in declarations:

declare module "some-npm-module" {
  export let a = 1;
  //           ^^^ Error
}

Fix: Replace with type definition.

Replace the initializer with an appropriate type definition:

declare module "some-npm-module" {
  export let a: number;
}