fix: walksScope throw error when path.parentPath is null (#25)

This commit is contained in:
martinoooo 2020-07-13 14:01:19 +08:00 committed by GitHub
parent 6f847c455c
commit d495546883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}