• Error
  • Reported by the type checker

TS2383

Overload signatures must all be exported or non-exported.

Some overload signatures of a function are exported and others aren't. Export all of them, or none.

What it means

All overloads of a function, and its implementation, form one declaration. They must agree on export.

Example

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

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

  • Add or remove export so every signature matches.