[estree] Fix conversion of PrivateName in MemberExpression (#13755)
* Update test * [estree] Fix conversion of `PrivateName` in `MemberExpression`
This commit is contained in:
parent
8af57dbfb7
commit
710b3919fa
@ -181,15 +181,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
classBody.body.push(method);
|
classBody.body.push(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseMaybePrivateName(...args: [boolean]): any {
|
parsePrivateName(): any {
|
||||||
const node = super.parseMaybePrivateName(...args);
|
const node = super.parsePrivateName();
|
||||||
if (
|
if (!this.getPluginOption("estree", "classFeatures")) {
|
||||||
node.type === "PrivateName" &&
|
return node;
|
||||||
this.getPluginOption("estree", "classFeatures")
|
|
||||||
) {
|
|
||||||
return this.convertPrivateNameToPrivateIdentifier(node);
|
|
||||||
}
|
}
|
||||||
return node;
|
return this.convertPrivateNameToPrivateIdentifier(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
convertPrivateNameToPrivateIdentifier(
|
convertPrivateNameToPrivateIdentifier(
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
class A {
|
class A {
|
||||||
#foo = "bar";
|
#foo = "bar";
|
||||||
static #bar = foo;
|
static #bar = foo;
|
||||||
|
|
||||||
|
method() {
|
||||||
|
this.#foo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
"start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":1}},
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
"start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":1}},
|
||||||
"sourceType": "script",
|
"sourceType": "script",
|
||||||
"interpreter": null,
|
"interpreter": null,
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "ClassDeclaration",
|
"type": "ClassDeclaration",
|
||||||
"start":0,"end":48,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
"start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":1}},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
||||||
@ -18,7 +18,7 @@
|
|||||||
"superClass": null,
|
"superClass": null,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "ClassBody",
|
"type": "ClassBody",
|
||||||
"start":8,"end":48,"loc":{"start":{"line":1,"column":8},"end":{"line":4,"column":1}},
|
"start":8,"end":81,"loc":{"start":{"line":1,"column":8},"end":{"line":8,"column":1}},
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "PropertyDefinition",
|
"type": "PropertyDefinition",
|
||||||
@ -52,6 +52,52 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"computed": false
|
"computed": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "MethodDefinition",
|
||||||
|
"start":50,"end":79,"loc":{"start":{"line":5,"column":2},"end":{"line":7,"column":3}},
|
||||||
|
"static": false,
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":50,"end":56,"loc":{"start":{"line":5,"column":2},"end":{"line":5,"column":8},"identifierName":"method"},
|
||||||
|
"name": "method"
|
||||||
|
},
|
||||||
|
"computed": false,
|
||||||
|
"kind": "method",
|
||||||
|
"value": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"start":56,"end":79,"loc":{"start":{"line":5,"column":8},"end":{"line":7,"column":3}},
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"expression": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":59,"end":79,"loc":{"start":{"line":5,"column":11},"end":{"line":7,"column":3}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":65,"end":75,"loc":{"start":{"line":6,"column":4},"end":{"line":6,"column":14}},
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start":65,"end":74,"loc":{"start":{"line":6,"column":4},"end":{"line":6,"column":13}},
|
||||||
|
"object": {
|
||||||
|
"type": "ThisExpression",
|
||||||
|
"start":65,"end":69,"loc":{"start":{"line":6,"column":4},"end":{"line":6,"column":8}}
|
||||||
|
},
|
||||||
|
"computed": false,
|
||||||
|
"property": {
|
||||||
|
"type": "PrivateIdentifier",
|
||||||
|
"start":70,"end":74,"loc":{"start":{"line":6,"column":9},"end":{"line":6,"column":13}},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"optional": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user