From bea63789a05c96f4e1b34e5e992a7c3e0d60eb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 1 Feb 2021 20:12:12 +0100 Subject: [PATCH] Use assertion instead of type cast --- packages/babel-traverse/src/path/modification.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/babel-traverse/src/path/modification.ts b/packages/babel-traverse/src/path/modification.ts index 3b0ffff60213..88ffe614f610 100644 --- a/packages/babel-traverse/src/path/modification.ts +++ b/packages/babel-traverse/src/path/modification.ts @@ -132,13 +132,12 @@ export function insertAfter( let { scope } = this; if (scope.path.isPattern()) { + t.assertExpression(node); + this.replaceWith( - t.callExpression( - t.arrowFunctionExpression([], this.node as t.Expression), - [], - ), + t.callExpression(t.arrowFunctionExpression([], node), []), ); - (this.get("callee.body") as NodePath).insertAfter(nodes); + (this.get("callee.body") as NodePath).insertAfter(nodes); return [this]; }