Remove private field shorthand

There seems to be tentative agreement to remove the private field
shorthand given the added confusion and edge cases involved with the
shorthand.

Refs: https://github.com/tc39/proposal-class-fields/issues/21
This commit is contained in:
Karl Cheng
2017-07-25 11:53:38 +10:00
parent 59ffa6268e
commit 42d5dbe544
12 changed files with 2937 additions and 2266 deletions

View File

@@ -331,14 +331,12 @@ export default class ExpressionParser extends LValParser {
if (arg.type === "Identifier") {
this.raise(node.start, "Deleting local variable in strict mode");
} else if (this.hasPlugin("classPrivateProperties")) {
if (
arg.type === "PrivateName" ||
(arg.type === "MemberExpression" &&
arg.property.type === "PrivateName")
) {
this.raise(node.start, "Deleting a private field is not allowed");
}
} else if (
this.hasPlugin("classPrivateProperties") &&
arg.type === "MemberExpression" &&
arg.property.type === "PrivateName"
) {
this.raise(node.start, "Deleting a private field is not allowed");
}
}
@@ -747,13 +745,6 @@ export default class ExpressionParser extends LValParser {
this.takeDecorators(node);
return this.parseClass(node, false);
case tt.hash:
if (this.hasPlugin("classPrivateProperties")) {
return this.parseMaybePrivateName();
} else {
throw this.unexpected();
}
case tt._new:
return this.parseNew();