From b0ebc65c18fcff7c9a3c656b2149e3c1d6982641 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Mon, 8 Aug 2022 00:17:42 -0500 Subject: [PATCH] Let path.remove() remove IfStatement.alternate Special-casing "consequent" makes sense, but there is no need to deviate from the normal `remove()` behavior for "alternate", which is permitted to be null. --- packages/babel-traverse/src/path/lib/removal-hooks.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/babel-traverse/src/path/lib/removal-hooks.js b/packages/babel-traverse/src/path/lib/removal-hooks.js index 20d7fba20e6e..0909bd26158a 100644 --- a/packages/babel-traverse/src/path/lib/removal-hooks.js +++ b/packages/babel-traverse/src/path/lib/removal-hooks.js @@ -60,8 +60,7 @@ export const hooks = [ function (self, parent) { if ( - (parent.isIfStatement() && - (self.key === "consequent" || self.key === "alternate")) || + (parent.isIfStatement() && self.key === "consequent") || (self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) ) {