Skip to content

Commit cb4aaf3

Browse files
committed
Correct handling if source file exports nothing
1 parent 2429429 commit cb4aaf3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/exports-symbol-tree.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ export class ExportsSymbolTree {
3434

3535
const typeChecker = this.program.getTypeChecker();
3636
for (const filePath of entrySourceFiles) {
37-
const entrySourceFile = typeChecker.getSymbolAtLocation(this.program.getSourceFile(filePath) as ts.SourceFile);
37+
const sourceFile = this.program.getSourceFile(filePath);
38+
if (sourceFile === undefined) {
39+
throw new Error(`Cannot find source file ${filePath}`);
40+
}
41+
42+
const entrySourceFile = typeChecker.getSymbolAtLocation(sourceFile);
3843
if (entrySourceFile === undefined) {
39-
throw new Error(`Cannot find symbol for source file ${filePath}`);
44+
// if a source file doesn't have any export - then it doesn't have a symbol as well
45+
// so just skip it here
46+
continue;
4047
}
4148

4249
for (const entryExportSymbol of getExportsForSourceFile(typeChecker, entrySourceFile)) {

0 commit comments

Comments
 (0)