Skip to content

Commit

Permalink
Support older typescript parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
christophercurrie committed May 12, 2019
1 parent 288cedf commit 67b1e95
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ ExportMap.parse = function (path, content, context) {
case 'ClassDeclaration':
case 'TypeAlias': // flowtype with babel-eslint parser
case 'InterfaceDeclaration':
case 'DeclareFunction':
case 'TSDeclareFunction':
case 'TSEnumDeclaration':
case 'TSTypeAliasDeclaration':
Expand Down Expand Up @@ -513,14 +514,20 @@ ExportMap.parse = function (path, content, context) {

// This doesn't declare anything, but changes what's being exported.
if (n.type === 'TSExportAssignment') {
const d = ast.body.find(
b => b.type === 'TSModuleDeclaration' && b.id.name === n.expression.name
const md = ast.body.find(
(b) => b.type === 'TSModuleDeclaration' && b.id.name === n.expression.name
)
if (d && d.body && d.body.body) {
d.body.body.forEach(b => {
if (md && md.body && md.body.body) {
md.body.body.forEach((b) => {
// Export-assignment exports all members in the namespace, explicitly exported or not.
const s = b.type === 'ExportNamedDeclaration' ? b.declaration : b
m.namespace.set(s.id.name, captureDoc(source, docStyleParsers, b))
if (s.type === 'VariableDeclaration') {
s.declarations.forEach((d) =>
recursivePatternCapture(d.id,
id => m.namespace.set(id.name, captureDoc(source, docStyleParsers, d, n))))
} else {
m.namespace.set(s.id.name, captureDoc(source, docStyleParsers, b))
}
})
}
}
Expand Down

0 comments on commit 67b1e95

Please sign in to comment.