diff --git a/packages/definitions-parser/src/lib/module-info.ts b/packages/definitions-parser/src/lib/module-info.ts index 6e9b5f1abf..18324a7662 100644 --- a/packages/definitions-parser/src/lib/module-info.ts +++ b/packages/definitions-parser/src/lib/module-info.ts @@ -275,14 +275,20 @@ function findReferencedFiles(src: ts.SourceFile, packageName: string, subDirecto * All strings referenced in `import` statements. * Does *not* include directives. */ -function* imports({ statements }: ts.SourceFile | ts.ModuleBlock): Iterable { +function imports({ statements }: ts.SourceFile | ts.ModuleBlock): Iterable { + const result: string[] = []; for (const node of statements) { + recur(node); + } + return result; + + function recur(node: ts.Node) { switch (node.kind) { case ts.SyntaxKind.ImportDeclaration: case ts.SyntaxKind.ExportDeclaration: { const { moduleSpecifier } = node as ts.ImportDeclaration | ts.ExportDeclaration; if (moduleSpecifier && moduleSpecifier.kind === ts.SyntaxKind.StringLiteral) { - yield (moduleSpecifier as ts.StringLiteral).text; + result.push((moduleSpecifier as ts.StringLiteral).text); } break; } @@ -290,20 +296,24 @@ function* imports({ statements }: ts.SourceFile | ts.ModuleBlock): Iterable