Skip to content

Commit

Permalink
Fix interface declarations for Typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
julien1619 committed May 31, 2020
1 parent eb2b7ea commit 949bf8d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ExportMap.js
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions 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
9 changes: 9 additions & 0 deletions tests/src/rules/namespace.js
Expand Up @@ -133,6 +133,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,
]

Expand Down

0 comments on commit 949bf8d

Please sign in to comment.