Skip to content

False "Multiple exports of name" error when two "export * as ..." contain same name [import/export]  #2289

Closed

Description

@butterybread

The issue I am having seems related to #1834
That specific issue is fixed. But I am having the same issue when using an extra level of indirection.
TypeScript does not seem to have a problem with the added level. So I guess this plugin should allow it...?

Scenario described in #1834

./A/A1.ts

export type X = "A1";

./A/A2.ts

export type X = "A2";

./A/index.ts

export * as A1 from "./A1";
export * as A2 from "./A2";

In this scenario, as described in #1834 there would be an error Multiple exports of name 'X'.
There is no error. This is fixed.

My scenario

I have the same files as above. With the following added:
./B/B.ts

export type X = "B";

./B/index.ts

export * as B from "./B";

./index.ts

export * from "./A";
export * from "./B";

Now I get the same error (Multiple exports of name 'X') again for both lines in ./index.ts.

Having added this extra level of indirection with the index.ts files seems to mess up something.

As the original problem, this error can also be avoided by doing:

./index.ts

import { A1, A2 } from "./A";
import { B } from "./B";
export { A1, A2, B };

versions

"eslint": "^7.32.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.25.2",
"typescript": "^4.4.4",

Activity

  1. ljharb commented on Nov 5, 2021

    @ljharb
    Member

    Yes, I agree this should work for export.

    However, I think export type is something we should always be ignoring, since typescript can check that.

  2. darrenvong commented on Feb 5, 2024

    @darrenvong

    Not sure how much this helps, but this issue was fixed for me from 2.25.2 up to 2.28.2 using eslint 8. 2.29.0 onwards is where I'm seeing the same issue again

  3. ljharb commented on Feb 5, 2024

    @ljharb
    Member

    @darrenvong that's very strange that it would be fixed and then regress. Thanks for the data point.

  4. ljharb commented on May 29, 2026

    @ljharb
    Member

    Fixed by #3250, now on main (ships in the next release). The false import/export "Multiple exports of name" error for two export * as re-exports sharing a name no longer reproduces with that change.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions