Skip to content

Commit

Permalink
Export nested namespace declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
julien1619 committed May 25, 2020
1 parent d7458a7 commit 373ee13
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/ExportMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,10 @@ ExportMap.parse = function (path, content, context) {
}
exportedDecls.forEach((decl) => {
if (decl.type === 'TSModuleDeclaration') {
let currentDecl = decl
let moduleDecls = [decl]

// Find recursive TSModuleDeclaration
while (currentDecl.body && currentDecl.body.type === 'TSModuleDeclaration') {
currentDecl = currentDecl.body
moduleDecls.push(currentDecl)
}

if (currentDecl.body && currentDecl.body.body) {
currentDecl.body.body.forEach((moduleBlockNode) => {
if (decl.body && decl.body.type === 'TSModuleDeclaration') {
m.namespace.set(decl.body.id.name, captureDoc(source, docStyleParsers, decl.body))
} else if (decl.body && decl.body.body) {
decl.body.body.forEach((moduleBlockNode) => {
// Export-assignment exports all members in the namespace,
// explicitly exported or not.
const namespaceDecl = moduleBlockNode.type === 'ExportNamedDeclaration' ?
Expand All @@ -573,13 +566,7 @@ ExportMap.parse = function (path, content, context) {
namespaceDecl.declarations.forEach((d) =>
recursivePatternCapture(d.id, (id) => m.namespace.set(
id.name,
captureDoc(
source,
docStyleParsers,
...moduleDecls,
namespaceDecl,
moduleBlockNode
)
captureDoc(source, docStyleParsers, decl, namespaceDecl, moduleBlockNode)
))
)
} else {
Expand Down

0 comments on commit 373ee13

Please sign in to comment.