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-unused-modules] Typescript namespace usage results in false positive #2336

Open
UwaisA opened this issue Dec 24, 2021 · 2 comments

Comments

@UwaisA
Copy link

UwaisA commented Dec 24, 2021

// Foo.ts
export namespace MyNamespace {
  export interface Internal {
    a: string;
  }
}
// Bar.ts
import { MyNamespace } from 'Foo';

export const internal: MyNamespace.Internal = { a: 'a' };
/src/Foo.ts
  2:3  error  exported declaration 'Internal' not used within other modules      import/no-unused-modules

Both the export of MyNamepsace and Internal seem to be required for the usage to compile in Bar.ts. I think this kind of usage should not result in any errors. The namespace in Foo.ts can be replaced with the module keyword and the same false positive is raised.

This seems to be in a similar area to #1964 but with a different rule.

@ekilah
Copy link

ekilah commented Feb 22, 2024

I've run into this as well, just commenting to bump this since it's a couple years old.

@ljharb
Copy link
Member

ljharb commented Feb 22, 2024

Using namespaces at all is super unidiomatic, but i agree we shouldn’t give the wrong answer.

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

No branches or pull requests

3 participants