Skip to content

export: handle type-only star re-exports separately#3260

Closed
morgan-coded wants to merge 2 commits into
import-js:mainfrom
morgan-coded:fix/3136-export-type-star-collision
Closed

export: handle type-only star re-exports separately#3260
morgan-coded wants to merge 2 commits into
import-js:mainfrom
morgan-coded:fix/3136-export-type-star-collision

Conversation

@morgan-coded

@morgan-coded morgan-coded commented Jun 3, 2026

Copy link
Copy Markdown

Problem I saw:
The export rule could report a duplicate export when a value export and a type-only star re-export exposed the same name.
One small shape that hit it was:
export { f } from './m'
export type * from './m'
That should not collide, since the second export is type-only. Thanks @mykola-mokhnach for the report.
What I changed:
I passed the ExportAllDeclaration export kind through to the named export tracking.
That keeps plain export * in the value side, but puts export type * in the type side.
How I checked it:
The focused regression test failed before the fix and passed after it.
I also ran:
npm run mocha -- tests/src/rules/export.js
npm run tests-only
ESLint was clean on the changed files.
Closes #3136

Copilot AI review requested due to automatic review settings June 3, 2026 16:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes false-positive duplicate export reports when a value export and export type * re-export expose the same name (TypeScript), aligning behavior with the TypeScript type/value namespace separation.

Changes:

  • Treat export type * re-exports as type-namespace entries when recording named exports.
  • Add a TypeScript test case (and fixture module) covering export { f } alongside export type *.
  • Document the fix in the changelog and link the tracked issue.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/src/rules/export.js Adds a TS regression test for export type * + value re-export, guarded by parser capability.
tests/files/export-type-star/m.ts Adds a fixture module used by the new regression test.
src/rules/export.js Records remote export names with type/value distinction for export type *.
CHANGELOG.md Notes the fix and adds issue/author references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/src/rules/export.js
Comment thread tests/src/rules/export.js Outdated
Comment on lines +343 to +344
// `export type *` requires a TypeScript 5.0-capable parser.
typescriptEslintParserSatisfies('>= 5.54') ? test({
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.86%. Comparing base (895fd8a) to head (e909363).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3260      +/-   ##
==========================================
+ Coverage   95.45%   95.86%   +0.41%     
==========================================
  Files          83       83              
  Lines        3737     3774      +37     
  Branches     1352     1374      +22     
==========================================
+ Hits         3567     3618      +51     
+ Misses        170      156      -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…f a value re-export

Handle `export type { x }` (declaration `exportKind`) and `export { type x }` (specifier `exportKind`) the same way `export type *` is,
routing the name into the type namespace so it does not collide with a same-named value re-export.
@ljharb ljharb force-pushed the fix/3136-export-type-star-collision branch from be687ef to e909363 Compare June 4, 2026 22:32
@ljharb ljharb reopened this Jun 15, 2026
@morgan-coded

Copy link
Copy Markdown
Author

Closing this — it's picked up conflicts with main and I'd rather not leave a stale PR sitting. If the change is still worth doing I can put up a fresh rebased version. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

"Multiple exports of name 'xxx' import/export" error is thrown if types are exported

3 participants