babel-helper-evaluate-path
Advanced tools
Comparing version 0.5.0-alpha.18dcfe13 to 0.5.0-alpha.1cb46b73
@@ -11,4 +11,2 @@ "use strict"; | ||
const t = require("@babel/types"); | ||
module.exports = function evaluate(path, { | ||
@@ -150,3 +148,8 @@ tdz = false | ||
if (t.isIfStatement(declaration.parentPath) || t.isLoop(declaration.parentPath) || t.isSwitchCase(declaration.parentPath)) { | ||
if (declaration.parentPath) { | ||
/** | ||
* Handle when binding is created inside a parent block and | ||
* the corresponding parent is removed by other plugins | ||
* if (false) { var a } -> var a | ||
*/ | ||
if (declaration.parentPath.removed) { | ||
@@ -159,5 +162,7 @@ return { | ||
return { | ||
shouldDeopt: true | ||
}; | ||
if (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase()) { | ||
return { | ||
shouldDeopt: true | ||
}; | ||
} | ||
} | ||
@@ -202,3 +207,3 @@ | ||
if (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase()) { | ||
if (declaration.parentPath && (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase())) { | ||
return { | ||
@@ -216,3 +221,8 @@ shouldDeopt: true | ||
const stmts = scopePath.get("body"); | ||
let stmts = scopePath.get("body"); | ||
if (!Array.isArray(stmts)) { | ||
stmts = [stmts]; | ||
} | ||
const compareResult = compareBindingAndReference({ | ||
@@ -219,0 +229,0 @@ binding, |
{ | ||
"name": "babel-helper-evaluate-path", | ||
"version": "0.5.0-alpha.18dcfe13", | ||
"version": "0.5.0-alpha.1cb46b73", | ||
"description": "path.evaluate wrapped in a try catch", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9524
263