Skip to content

Commit

Permalink
Correct handling if source file exports nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
timocov committed Sep 14, 2020
1 parent 2429429 commit cb4aaf3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/exports-symbol-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ export class ExportsSymbolTree {

const typeChecker = this.program.getTypeChecker();
for (const filePath of entrySourceFiles) {
const entrySourceFile = typeChecker.getSymbolAtLocation(this.program.getSourceFile(filePath) as ts.SourceFile);
const sourceFile = this.program.getSourceFile(filePath);
if (sourceFile === undefined) {
throw new Error(`Cannot find source file ${filePath}`);
}

const entrySourceFile = typeChecker.getSymbolAtLocation(sourceFile);
if (entrySourceFile === undefined) {
throw new Error(`Cannot find symbol for source file ${filePath}`);
// if a source file doesn't have any export - then it doesn't have a symbol as well
// so just skip it here
continue;
}

for (const entryExportSymbol of getExportsForSourceFile(typeChecker, entrySourceFile)) {
Expand Down

0 comments on commit cb4aaf3

Please sign in to comment.