the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

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>;
}