Improves error message when super is called outside of constructor (#408)

This commit is contained in:
Arshabh Kumar Agarwal 2017-03-22 03:14:21 +05:30 committed by Henry Zhu
parent 0f982799b6
commit 964105e3fb
2 changed files with 3 additions and 3 deletions

View File

@ -392,7 +392,7 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
this.unexpected();
}
if (this.match(tt.parenL) && this.state.inMethod !== "constructor" && !this.options.allowSuperOutsideMethod) {
this.raise(node.start, "super() outside of class constructor");
this.raise(node.start, "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'.");
}
return this.finishNode(node, "Super");

View File

@ -1,3 +1,3 @@
{
"throws": "super() outside of class constructor (2:8)"
}
"throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (2:8)"
}