Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Add check for node.body in referencer #2

Merged
merged 10 commits into from
Feb 11, 2017
14 changes: 9 additions & 5 deletions src/referencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,15 @@ export default class Referencer extends esrecurse.Visitor {
});
}

// Skip BlockStatement to prevent creating BlockStatement scope.
if (node.body.type === Syntax.BlockStatement) {
this.visitChildren(node.body);
} else {
this.visit(node.body);
// In TypeScript there are a number of function-like constructs which have no body,
// so check it exists before traversing
if (node.body) {
// Skip BlockStatement to prevent creating BlockStatement scope.
if (node.body.type === Syntax.BlockStatement) {
this.visitChildren(node.body);
} else {
this.visit(node.body);
}
}

this.close(node);
Expand Down