@babel/plugin-proposal-optional-chaining
Advanced tools
Comparing version 7.17.12 to 7.18.6
@@ -80,4 +80,3 @@ 'use strict'; | ||
} = optionalPath; | ||
const childKey = optionalPath.isOptionalMemberExpression() ? "object" : "callee"; | ||
const childPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get(childKey)); | ||
const childPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.isOptionalMemberExpression() ? optionalPath.get("object") : optionalPath.get("callee")); | ||
@@ -146,4 +145,3 @@ if (node.optional) { | ||
const isCall = core.types.isCallExpression(node); | ||
const replaceKey = isCall ? "callee" : "object"; | ||
const chainWithTypes = node[replaceKey]; | ||
const chainWithTypes = isCall ? node.callee : node.object; | ||
const chain = helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes(chainWithTypes); | ||
@@ -157,5 +155,5 @@ let ref; | ||
check = ref = chain; | ||
node[replaceKey] = core.types.sequenceExpression([core.types.numericLiteral(0), ref]); | ||
node.callee = core.types.sequenceExpression([core.types.numericLiteral(0), ref]); | ||
} else if (pureGetters && isCall && isSimpleMemberExpression(chain)) { | ||
check = ref = chainWithTypes; | ||
check = ref = node.callee; | ||
} else { | ||
@@ -166,3 +164,3 @@ ref = scope.maybeGenerateMemoised(chain); | ||
check = core.types.assignmentExpression("=", core.types.cloneNode(ref), chainWithTypes); | ||
node[replaceKey] = ref; | ||
isCall ? node.callee = ref : node.object = ref; | ||
} else { | ||
@@ -169,0 +167,0 @@ check = ref = chainWithTypes; |
{ | ||
"name": "@babel/plugin-proposal-optional-chaining", | ||
"version": "7.17.12", | ||
"version": "7.18.6", | ||
"description": "Transform optional chaining operators into a series of nil checks", | ||
@@ -20,4 +20,4 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.17.12", | ||
"@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", | ||
"@babel/helper-plugin-utils": "^7.18.6", | ||
"@babel/helper-skip-transparent-expression-wrappers": "^7.18.6", | ||
"@babel/plugin-syntax-optional-chaining": "^7.8.3" | ||
@@ -29,6 +29,6 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.17.12", | ||
"@babel/helper-plugin-test-runner": "^7.16.7", | ||
"@babel/plugin-transform-block-scoping": "^7.17.12", | ||
"@babel/traverse": "^7.17.12" | ||
"@babel/core": "^7.18.6", | ||
"@babel/helper-plugin-test-runner": "^7.18.6", | ||
"@babel/plugin-transform-block-scoping": "^7.18.6", | ||
"@babel/traverse": "^7.18.6" | ||
}, | ||
@@ -38,3 +38,4 @@ "engines": { | ||
}, | ||
"author": "The Babel Team (https://babel.dev/team)" | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
"type": "commonjs" | ||
} |
Sorry, the diff of this file is not supported yet
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
32738
209