[parser] Parse only modifiers of actual methods (#10594)
* Parse only modifiers of actual methods * Throw question token if is used before the real name
This commit is contained in:
@@ -1348,6 +1348,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
const isPrivate = key.type === "PrivateName";
|
||||
// Check the key is not a computed expression or string literal.
|
||||
const isSimple = key.type === "Identifier";
|
||||
const maybeQuestionTokenStart = this.state.start;
|
||||
|
||||
this.parsePostMemberNameModifiers(publicMember);
|
||||
|
||||
@@ -1403,6 +1404,10 @@ export default class StatementParser extends ExpressionParser {
|
||||
// an async method
|
||||
const isGenerator = this.eat(tt.star);
|
||||
|
||||
if (publicMember.optional) {
|
||||
this.unexpected(maybeQuestionTokenStart);
|
||||
}
|
||||
|
||||
method.kind = "method";
|
||||
// The so-called parsed name would have been "async": get the real name.
|
||||
this.parseClassPropertyName(method);
|
||||
|
||||
Reference in New Issue
Block a user