diff --git a/src/ast/nodes/IfStatement.ts b/src/ast/nodes/IfStatement.ts index 2fb3510d33d..b828353f53a 100644 --- a/src/ast/nodes/IfStatement.ts +++ b/src/ast/nodes/IfStatement.ts @@ -70,12 +70,18 @@ export default class IfStatement extends StatementBase implements DeoptimizableE parseNode(esTreeNode: GenericEsTreeNode) { this.consequentScope = new TrackingScope(this.scope); - this.consequent = new (this.context.nodeConstructors[esTreeNode.consequent.type] || - this.context.nodeConstructors.UnknownNode)(esTreeNode.consequent, this, this.consequentScope); + this.consequent = new this.context.nodeConstructors[esTreeNode.consequent.type]( + esTreeNode.consequent, + this, + this.consequentScope + ); if (esTreeNode.alternate) { this.alternateScope = new TrackingScope(this.scope); - this.alternate = new (this.context.nodeConstructors[esTreeNode.alternate.type] || - this.context.nodeConstructors.UnknownNode)(esTreeNode.alternate, this, this.alternateScope); + this.alternate = new this.context.nodeConstructors[esTreeNode.alternate.type]( + esTreeNode.alternate, + this, + this.alternateScope + ); } super.parseNode(esTreeNode); } diff --git a/src/ast/scopes/BlockScope.ts b/src/ast/scopes/BlockScope.ts index 45bda1fe7f1..b72bcc3a19e 100644 --- a/src/ast/scopes/BlockScope.ts +++ b/src/ast/scopes/BlockScope.ts @@ -9,7 +9,7 @@ export default class BlockScope extends ChildScope { addDeclaration( identifier: Identifier, context: AstContext, - init: ExpressionEntity | null = null, + init: ExpressionEntity | null, isHoisted: boolean ): LocalVariable { if (isHoisted) { diff --git a/src/ast/scopes/Scope.ts b/src/ast/scopes/Scope.ts index e38a5b068bc..32a46d31719 100644 --- a/src/ast/scopes/Scope.ts +++ b/src/ast/scopes/Scope.ts @@ -13,7 +13,7 @@ export default class Scope { addDeclaration( identifier: Identifier, context: AstContext, - init: ExpressionEntity | null = null, + init: ExpressionEntity | null, _isHoisted: boolean ) { const name = identifier.name; diff --git a/src/ast/scopes/TrackingScope.ts b/src/ast/scopes/TrackingScope.ts index 46c65dad892..a7e443bbf5c 100644 --- a/src/ast/scopes/TrackingScope.ts +++ b/src/ast/scopes/TrackingScope.ts @@ -13,9 +13,7 @@ export default class TrackingScope extends BlockScope { init: ExpressionEntity | null = null, isHoisted: boolean ): LocalVariable { - if (isHoisted) { - this.hoistedDeclarations.push(identifier); - } + this.hoistedDeclarations.push(identifier); return this.parent.addDeclaration(identifier, context, init, isHoisted); } }