• Error
  • Reported by the binder

TS2528

A module cannot have multiple default exports.

A module has more than one default export. Keep one export default and turn the others into named exports.

What it means

A module has a single default export. Two export default statements (or a default class and a default function) in the same file are reported on each.

Example

index.ts
const start = 1;
const stop = 2;
export default start;
export default stop;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,16): error TS2528: A module cannot have multiple default exports.
index.ts(4,16): error TS2528: A module cannot have multiple default exports.

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

  • Keep one default export and make the others named: export function stop() {}.
  • Or export a single object that holds both.