Add static private class field support
This commit is contained in:
@@ -922,15 +922,6 @@ export default class StatementParser extends ExpressionParser {
|
||||
const method: N.ClassMethod = memberAny;
|
||||
const prop: N.ClassProperty = memberAny;
|
||||
|
||||
if (this.hasPlugin("classPrivateProperties") && this.match(tt.hash)) {
|
||||
// Private property
|
||||
this.next();
|
||||
const privateProp: N.ClassPrivateProperty = memberAny;
|
||||
privateProp.key = this.parseIdentifier(true);
|
||||
classBody.body.push(this.parsePrivateClassProperty(privateProp));
|
||||
return;
|
||||
}
|
||||
|
||||
let isStatic = false;
|
||||
if (this.match(tt.name) && this.state.value === "static") {
|
||||
const key = this.parseIdentifier(true); // eats 'static'
|
||||
@@ -960,6 +951,16 @@ export default class StatementParser extends ExpressionParser {
|
||||
isStatic = true;
|
||||
}
|
||||
|
||||
if (this.hasPlugin("classPrivateProperties") && this.match(tt.hash)) {
|
||||
// Private property
|
||||
this.next();
|
||||
const privateProp: N.ClassPrivateProperty = memberAny;
|
||||
privateProp.key = this.parseIdentifier(true);
|
||||
privateProp.static = isStatic;
|
||||
classBody.body.push(this.parsePrivateClassProperty(privateProp));
|
||||
return;
|
||||
}
|
||||
|
||||
this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
|
||||
}
|
||||
|
||||
|
||||
@@ -680,6 +680,7 @@ export type ClassPrivateProperty = NodeBase & {
|
||||
type: "ClassPrivateProperty",
|
||||
key: Identifier,
|
||||
value: ?Expression, // TODO: Not in spec that this is nullable.
|
||||
static: boolean,
|
||||
};
|
||||
|
||||
export type OptClassDeclaration = ClassBase &
|
||||
|
||||
Reference in New Issue
Block a user