the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

Editing TS1040:

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.

TS1040

'{0}' modifier cannot be used in an ambient context.

The async keyword only impacts implementation code and therefore isn't valid in an ambient/declaration context. Therefore the following is an error:

declare module "some-npm-module" {
  export async function test(): Promise<void>;
  //     ^^^^^ Error
}

Fix: Remove async keyword.

Remove the async keyword:

declare module "some-npm-module" {
  export function test(): Promise<void>;
}