@babel/plugin-proposal-optional-chaining
Advanced tools
Comparing version 7.11.0 to 7.12.0
@@ -29,2 +29,23 @@ "use strict"; | ||
function needsMemoize(path) { | ||
let optionalPath = path; | ||
const { | ||
scope | ||
} = path; | ||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) { | ||
const { | ||
node | ||
} = optionalPath; | ||
const childKey = optionalPath.isOptionalMemberExpression() ? "object" : "callee"; | ||
const childPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get(childKey)); | ||
if (node.optional) { | ||
return !scope.isStatic(childPath.node); | ||
} | ||
optionalPath = childPath; | ||
} | ||
} | ||
return { | ||
@@ -50,2 +71,7 @@ name: "proposal-optional-chaining", | ||
if (scope.path.isPattern() && needsMemoize(optionalPath)) { | ||
path.replaceWith(_core.template.ast`(() => ${path.node})()`); | ||
return; | ||
} | ||
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) { | ||
@@ -52,0 +78,0 @@ const { |
{ | ||
"name": "@babel/plugin-proposal-optional-chaining", | ||
"version": "7.11.0", | ||
"version": "7.12.0", | ||
"description": "Transform optional chaining operators into a series of nil checks", | ||
@@ -27,6 +27,6 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.11.0", | ||
"@babel/core": "^7.12.0", | ||
"@babel/helper-plugin-test-runner": "^7.10.4", | ||
"@babel/plugin-transform-block-scoping": "^7.10.4" | ||
} | ||
} | ||
} |
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
9381
148