Skip to content

Commit

Permalink
findImports: fix crash on nested namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff committed Jul 25, 2019
1 parent eae53d0 commit 1a472b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,20 @@ class ImportFinder {
} else if (isExportDeclaration(statement)) {
if (statement.moduleSpecifier !== undefined && this._options & ImportKind.ExportFrom)
this._result.push(<any>statement);
} else if (isModuleDeclaration(statement) && statement.body !== undefined) {
this._findImports((<ts.ModuleBlock>statement.body).statements);
} else if (isModuleDeclaration(statement)) {
this._findImportsInModule(statement);
}
}
}

private _findImportsInModule(declaration: ts.ModuleDeclaration): void {
if (declaration.body === undefined)
return;
if (declaration.body.kind === ts.SyntaxKind.ModuleDeclaration)
return this._findImportsInModule(declaration.body);
this._findImports((<ts.ModuleBlock>declaration.body).statements);
}

private _findNestedImports() {
let re;
if ((this._options & ImportKind.AllNestedImports) === ImportKind.Require) {
Expand Down

0 comments on commit 1a472b7

Please sign in to comment.