diff --git a/src/ExportMap.js b/src/ExportMap.js index 5a36b220b8..95720296e3 100644 --- a/src/ExportMap.js +++ b/src/ExportMap.js @@ -543,7 +543,10 @@ ExportMap.parse = function (path, content, context) { ] const exportedDecls = ast.body.filter(({ type, id, declarations }) => declTypes.includes(type) && - (id && id.name === exportedName || declarations.find(d => d.id.name === exportedName)) + ( + (id && id.name === exportedName) || + (declarations && declarations.find(d => d.id.name === exportedName)) + ) ) if (exportedDecls.length === 0) { // Export is not referencing any local declaration, must be re-exporting diff --git a/tests/files/typescript-declare-interface.d.ts b/tests/files/typescript-declare-interface.d.ts new file mode 100644 index 0000000000..b572b62e90 --- /dev/null +++ b/tests/files/typescript-declare-interface.d.ts @@ -0,0 +1,11 @@ +declare interface foo { + a: string; +} + +declare namespace SomeNamespace { + type foobar = foo & { + b: string; + } +} + +export = SomeNamespace diff --git a/tests/src/rules/namespace.js b/tests/src/rules/namespace.js index cfc6305d5a..fb3fc81344 100644 --- a/tests/src/rules/namespace.js +++ b/tests/src/rules/namespace.js @@ -1,4 +1,4 @@ -import { test, SYNTAX_CASES } from '../utils' +import { test, SYNTAX_CASES, getTSParsers } from '../utils' import { RuleTester } from 'eslint' var ruleTester = new RuleTester({ env: { es6: true }}) @@ -120,6 +120,15 @@ const valid = [ }, }), + ...getTSParsers().map((parser) => test({ + code: `import { foobar } from "./typescript-declare-interface"`, + parser: parser, + settings: { + 'import/parsers': { [parser]: ['.ts'] }, + 'import/resolver': { 'eslint-import-resolver-typescript': true }, + }, + })), + ...SYNTAX_CASES, ]