Skip to content

Commit

Permalink
Added support for exported TS Module nodes (which also handle TS Name…
Browse files Browse the repository at this point in the history
…spaces)
  • Loading branch information
spencerhakim committed Oct 23, 2017
1 parent 96fb89d commit 3a7b412
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ ExportMap.parse = function (path, content, context) {
switch (n.type) {
case 'TSEnumDeclaration':
case 'TSInterfaceDeclaration':
case 'TSModuleDeclaration':
if (n.modifiers.some(mod => mod.type === 'TSExportKeyword')) {
m.namespace.set(n.name.name, captureDoc(docStyleParsers, n))
return
Expand Down
10 changes: 9 additions & 1 deletion tests/files/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ export enum MyEnum {
}

export module MyModule {
export function Whatever(){}
export function ModuleFunction(){}
}

export namespace MyNamespace {
export function NamespaceFunction(){}

export module NSModule {
export function NSModuleFunction(){}
}
}
22 changes: 22 additions & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ ruleTester.run('named', rule, {
'import/resolver': { 'eslint-import-resolver-typescript': true },
},
}),
test({
code: `
import { MyModule } from "./typescript"
MyModule.ModuleFunction()
`,
parser: 'typescript-eslint-parser',
settings: {
'import/parsers': { 'typescript-eslint-parser': ['.ts'] },
'import/resolver': { 'eslint-import-resolver-typescript': true },
},
}),
test({
code: `
import { MyNamespace } from "./typescript"
MyNamespace.NSModule.NSModuleFunction()
`,
parser: 'typescript-eslint-parser',
settings: {
'import/parsers': { 'typescript-eslint-parser': ['.ts'] },
'import/resolver': { 'eslint-import-resolver-typescript': true },
},
}),

// jsnext
test({
Expand Down

0 comments on commit 3a7b412

Please sign in to comment.