Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zimmed opened this issue Jun 23, 2020 · 2 comments
Labels

Comments

@zimmed
Copy link

zimmed commented Jun 23, 2020

Apologies if this is a duplicate -- it's difficult to search terms with an asterisk.

Found issue using:
eslint 6.6.0, 6.8.0, 7.3.1
eslint-plugin-import 2.20.2, 2.21.2
(tried various versions to see if it had already been fixed)

Setup:

// A.js
export const FOO = 'a-foobar';
// B.js
export const FOO = 'b-foobar';
// C.js
export * as A from './A';
export * as B from './B';

Expected:

No import/export error in C.js, since both instances of FOO are under their own namespaces (A/B).

import * as C from './C';

console.log(C.A.FOO); // 'a-foobar'
console.log(C.B.FOO); // 'b-foobar'
console.log(C.FOO); // undefined

Result:

Error in C.js:
Multiple exports of name 'FOO'. eslint(import/export)

Workaround

The following equivalent method works without errors, but annoying because ESLint is preventing me from taking advantage of newer ES syntax:

import * as A from './A';
import * as B from './B';

export { A, B };
@ljharb
Copy link
Member

ljharb commented Jun 23, 2020

This might be a duplicate of #518?

@zimmed
Copy link
Author

zimmed commented Jun 23, 2020

This might be a duplicate of #518?

That seems to be related to shadowing, whereas this example has no actual variable shadowing. If it was...

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

Then that would likely be the issue, but since the original code posted is equivalent to:

import * as A from './A';
import * as B from './B';

export { A, B };

There are no shadowed variable names, since FOO only exists within the individual namespaces. (This works without lint errors, by the way).

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

No branches or pull requests

2 participants