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/no-duplicates] False positive on imports in different typescript ambient modules #2091

Closed
chbdetta opened this issue May 21, 2021 · 5 comments

Comments

@chbdetta
Copy link

In an ambient file global.d.ts

declare module 'A' {
  import { ReactNode } from 'react';
}

declare module 'B' {
  import { ReactNode } from 'react';
}

import/no-duplicates complains about importing 'react' twice.

@ljharb
Copy link
Member

ljharb commented May 21, 2021

Duplicate of #2054.

@ljharb ljharb closed this as completed May 21, 2021
@chbdetta
Copy link
Author

chbdetta commented May 24, 2021

Is this a duplicate of #2054?
That issue is about importing the same library at the root level module. But here the importing happens in two different typescript ambient modules although they are declared in the same file.

@ljharb
Copy link
Member

ljharb commented May 24, 2021

I think it's the same issue in that the problem is the typescript resolver pointing multiple modules to the same d.ts file, masking the actual value-space location that should be checked.

@chbdetta
Copy link
Author

However, the plugin here seems to treat the import in two different typescript modules (A and B) as in one module.

I am expecting the plugin to treat the scope for module A and module B as they are defined in different files.

@ljharb
Copy link
Member

ljharb commented May 24, 2021

Right - that's the issue in #2054. Both modules resolved to the same file, so the plugin considers them the same module.

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

No branches or pull requests

2 participants