Disallow in object literals, params, class props

And add tests to reflect the same
This commit is contained in:
Peeyush Kushwaha
2017-06-17 17:49:33 +05:30
parent 162bc905a6
commit 9c639743dd
33 changed files with 727 additions and 178 deletions

View File

@@ -709,6 +709,10 @@ export default class StatementParser extends ExpressionParser {
}
this.parseClassMember(classBody, member, state);
if (this.hasPlugin("decorators-stage-2") && member.kind != "method" && member.decorators && member.decorators.length > 0) {
this.raise(member.start, "Stage 2 decorators may only be used with a class or a class method");
}
}
if (decorators.length) {
@@ -776,6 +780,7 @@ export default class StatementParser extends ExpressionParser {
if (!methodOrProp.computed && methodOrProp.static && (methodOrProp.key.name === "prototype" || methodOrProp.key.value === "prototype")) {
this.raise(methodOrProp.key.start, "Classes may not have static property named prototype");
}
if (this.isClassMethod()) {
// a normal method
if (this.isNonstaticConstructor(method)) {