From 964105e3fbd2084be0992bfdff3373c064e3d630 Mon Sep 17 00:00:00 2001 From: Arshabh Kumar Agarwal Date: Wed, 22 Mar 2017 03:14:21 +0530 Subject: [PATCH] Improves error message when super is called outside of constructor (#408) --- src/parser/expression.js | 2 +- .../direct-super-outside-constructor/options.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser/expression.js b/src/parser/expression.js index f974459462..5c9ebd588f 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -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"); diff --git a/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json b/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json index 476bc13a2b..faef53359b 100644 --- a/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json +++ b/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json @@ -1,3 +1,3 @@ { - "throws": "super() outside of class constructor (2:8)" -} \ No newline at end of file + "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (2:8)" +}