Disallow private name in object elements and TS type elements (#10980)
* fix: disallow private name in object member and TS type elements * chore: update test262 whitelist * chore: make flow happy * Update packages/babel-parser/src/parser/expression.js Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> * chore: update test fixtures * Update packages/babel-parser/src/parser/expression.js Co-Authored-By: Brian Ng <bng412@gmail.com> * chore: update test fixtures Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
@@ -2266,9 +2266,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
parsePropertyName(
|
||||
node: N.ObjectOrClassMember | N.ClassMember | N.TsNamedTypeElementBase,
|
||||
isPrivateNameAllowed: boolean,
|
||||
): N.Identifier {
|
||||
const variance = this.flowParseVariance();
|
||||
const key = super.parsePropertyName(node);
|
||||
const key = super.parsePropertyName(node, isPrivateNameAllowed);
|
||||
// $FlowIgnore ("variance" not defined on TsNamedTypeElementBase)
|
||||
node.variance = variance;
|
||||
return key;
|
||||
|
||||
@@ -507,7 +507,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return idx;
|
||||
}
|
||||
|
||||
this.parsePropertyName(node);
|
||||
this.parsePropertyName(node, /* isPrivateNameAllowed */ false);
|
||||
return this.tsParsePropertyOrMethodSignature(node, readonly);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user