From 4001fed40b7cc42f25b35d13ad884f7bdbc55f84 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/babel-traverse/src/path/modification.ts b/packages/babel-traverse/src/path/modification.ts index 3b0ffff60213..7aa5865446d4 100644 --- a/packages/babel-traverse/src/path/modification.ts +++ b/packages/babel-traverse/src/path/modification.ts @@ -132,11 +132,10 @@ 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); return [this];