diff --git a/src/Visitor.js b/src/Visitor.js index 18c8858..993db22 100644 --- a/src/Visitor.js +++ b/src/Visitor.js @@ -467,7 +467,9 @@ export default class Visitor extends BasicVisitor { visitConditional(node: Conditional) { this.descend(node.condition); - this.descend(node.consequent); + if (node.consequent) { + this.descend(node.consequent); + } if (node.alternate) { this.descend(node.alternate); } diff --git a/src/types.js b/src/types.js index 99affe9..df715ea 100644 --- a/src/types.js +++ b/src/types.js @@ -153,7 +153,7 @@ export type CompoundAssignOp = { export type Conditional = { type: 'Conditional'; condition: Expression; - consequent: Block; + consequent: ?Block; alternate: ?Block; isUnless: boolean; raw: string; diff --git a/types.json b/types.json index 3bc29ec..69c3285 100644 --- a/types.json +++ b/types.json @@ -190,7 +190,7 @@ }, { "name": "consequent", - "type": "Block" + "type": "?Block" }, { "name": "alternate",