OptionalMemberExpression properties are not referenced (#7668)

Fixes #7642.
This commit is contained in:
Justin Ridgewell 2018-04-05 02:44:32 +01:00 committed by GitHub
parent 56cb4baf46
commit 01f4c2368e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -17,6 +17,7 @@
},
"devDependencies": {
"@babel/core": "7.0.0-beta.44",
"@babel/helper-plugin-test-runner": "7.0.0-beta.44"
"@babel/helper-plugin-test-runner": "7.0.0-beta.44",
"@babel/plugin-transform-block-scoping": "7.0.0-beta.44"
}
}

View File

@ -0,0 +1,7 @@
{
const foo = 1;
}
{
const foo = ({})?.foo;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["proposal-optional-chaining", "transform-block-scoping"]
}

View File

@ -0,0 +1,8 @@
{
var foo = 1;
}
{
var _ref;
var _foo = (_ref = {}) === null || _ref === void 0 ? void 0 : _ref.foo;
}

View File

@ -14,6 +14,7 @@ export default function isReferenced(node: Object, parent: Object): boolean {
// no: parent.NODE
case "MemberExpression":
case "JSXMemberExpression":
case "OptionalMemberExpression":
if (parent.property === node && parent.computed) {
return true;
} else if (parent.object === node) {