import-js/eslint-plugin-import

[import/no-unused-modules] Typescript `namespace` usage results in false positive

Open

#2,336 创建于 2021年12月24日

在 GitHub 查看
 (2 评论) (4 反应) (0 负责人)JavaScript (1,540 fork)batch import
help wantedtypescript

仓库指标

Star
 (4,946 star)
PR 合并指标
 (平均合并 138天 22小时) (30 天内合并 3 个 PR)

描述

// 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 https://github.com/import-js/eslint-plugin-import/issues/1964 but with a different rule.

贡献者指南