• Error
  • Reported by the type checker

TS2384

Overload signatures must all be ambient or non-ambient.

Some overload signatures of a function are `declare`d (ambient) and others aren't. Make them all the same.

What it means

All overloads of a function must agree on declare: either they all describe a function implemented elsewhere, or they are all part of this file's implementation.

Example

index.ts
declare function parse(s: string): number;
function parse(s: number): number;
function parse(s: string | number): number {
  return Number(s);
}
export { parse };
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,18): error TS2384: Overload signatures must all be ambient or non-ambient.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Remove declare from the overloads that have an implementation here, or add it to all of them (and remove the body).