Allow super in class properties (#499)

This commit is contained in:
Brian Ng
2017-05-02 13:41:10 -05:00
committed by Henry Zhu
parent 9660f06b25
commit d33c82781a
6 changed files with 291 additions and 3 deletions

View File

@@ -772,19 +772,23 @@ export default class StatementParser extends ExpressionParser {
}
parseClassProperty(node) {
const hasPlugin = this.hasPlugin("classProperties");
const noPluginMsg = "You can only use Class Properties when the 'classProperties' plugin is enabled.";
if (!node.typeAnnotation && !this.hasPlugin("classProperties")) {
if (!node.typeAnnotation && !hasPlugin) {
this.raise(node.start, noPluginMsg);
}
this.state.inClassProperty = true;
if (this.match(tt.eq)) {
if (!this.hasPlugin("classProperties")) this.raise(this.state.start, noPluginMsg);
if (!hasPlugin) this.raise(this.state.start, noPluginMsg);
this.next();
node.value = this.parseMaybeAssign();
} else {
node.value = null;
}
this.semicolon();
this.state.inClassProperty = false;
return this.finishNode(node, "ClassProperty");
}