oxc-project/oxc · error · OxcDiagnostic
Multiple exports of name '{name}'.
Error message
Multiple exports of name '{name}'. What it means
The star-conflict branch of `import/export`'s duplicate-name check: a name that this module exports directly also appears among the named exports of a module reached through `export *`. The diagnostic labels both the local export span and every conflicting star-export span (built with `LabeledSpan::underline`) so the shadowing is visible.
Source
Thrown at crates/oxc_linter/src/rules/import/export.rs:106
} else {
all_export_names.insert(star_export_entry.span, export_names);
}
});
for (name, span) in named_export {
let mut spans = all_export_names
.iter()
.filter_map(|(star_export_entry_span, export_names)| {
if export_names.contains(name) { Some(*star_export_entry_span) } else { None }
})
.collect::<Vec<_>>();
if !spans.is_empty() {
spans.push(*span);
let labels = spans.into_iter().map(LabeledSpan::underline).collect::<Vec<_>>();
ctx.diagnostic(
OxcDiagnostic::warn(format!("Multiple exports of name '{name}'."))
.with_help("Rename or remove the duplicate export so each name is exported only once.")
.with_labels(labels),
);
}
}
}
}
struct ExportNameSpans {
spans: Vec<Span>,
has_named_specifier: bool,
}
fn diagnose_duplicate_named_exports(ctx: &LintContext<'_>, module_record: &ModuleRecord) {
let mut export_names: FxHashMap<(CompactStr, bool), ExportNameSpans> = FxHashMap::default();
module_record
.local_export_entriesView on GitHub (pinned to e1e7af627c)
Solutions
- Rename or remove the local export so it no longer collides with the star-exported name
- Replace `export *` with an explicit named list that omits the colliding name
- Namespace the re-export: `export * as mod from './mod';`
Example fix
// before — 'a' exists locally and is also exported by mod
export const a = 1;
export * from './mod';
// after
export const a = 1;
export { b, c } from './mod'; // explicit list, omit 'a' Defensive patterns
Strategy: validation
Validate before calling
// .oxlintrc.json
{
"plugins": ["import"],
"rules": { "import/export": "error" }
}
// CI gate: npx oxlint src/ && npx tsc --noEmit // tsc also flags ambiguous star re-exports Prevention
- Before adding an export next to an export *, check the star target for the same name
- Prefer explicit named re-exports in barrels over star exports
- Run both oxlint and tsc in CI — the compiler also reports ambiguous module exports
- Keep barrel files small and reviewed
When it happens
Trigger: `export const a = 1;` together with `export * from './mod';` where mod also exports `a` — the star re-export of that name is shadowed by the local export, and both sites are reported.
Common situations: Barrel index files adding star exports next to local constants; two package versions re-exporting the same helper name; adding a new local export that collides with one already re-exported from a dependency.
Related errors
- No named exports found in module '{module_name}'
- Type imports from declaration files must use top-level `impo
- Prefer using inline type specifiers instead of a top-level t
- Prefer using a top-level type-only import instead of inline
- Prefer using a top-level type-only import instead of inline
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/db2355536229ca4b.
Report an issue: GitHub.