From d4955468839568ccc8ede6b3949ee743f134f141 Mon Sep 17 00:00:00 2001 From: martinoooo Date: Mon, 13 Jul 2020 14:01:19 +0800 Subject: [PATCH] fix: walksScope throw error when path.parentPath is null (#25) --- packages/babel-plugin-jsx/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-plugin-jsx/src/utils.ts b/packages/babel-plugin-jsx/src/utils.ts index 58eb701..2fb562b 100644 --- a/packages/babel-plugin-jsx/src/utils.ts +++ b/packages/babel-plugin-jsx/src/utils.ts @@ -275,7 +275,7 @@ const parseDirectives = (args: { }; const walksScope = (path: NodePath, name: string) => { - if (path.scope.hasBinding(name)) { + if (path.scope.hasBinding(name) && path.parentPath) { path.parentPath.setData('optimize', false); walksScope(path.parentPath, name); }