import-js/eslint-plugin-import

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

Closed

#2,289 opened on Nov 4, 2021

 (3 comments) (2 reactions) (0 assignees)JavaScript (1,550 forks)batch import
bughelp wanted

Repository metrics

Stars
 (5,940 stars)
PR merge metrics
 (Avg merge 138d 22h) (3 merged PRs in 30d)

Description

The issue I am having seems related to https://github.com/import-js/eslint-plugin-import/issues/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 https://github.com/import-js/eslint-plugin-import/issues/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 https://github.com/import-js/eslint-plugin-import/issues/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",

Contributor guide