Reputation: 2264
I've been trying to convert all my coffee-scripts into a bundle using webpack.
But I am stuck at one part.
It was giving following error
error: unexpected indentation
super
I've a small snippet of the the code.
class p
check: (x,y,z) ->
if x and y
super
else
if y
x = y
else
super
I am able to reproduce this error when I've checked it in http://coffeescript.org/
However, http://js2.coffee/ was able to convert it to javascript.
Go to the above sites and paste the above code snippet there.
I've also tried to convert it to different online tools.
Upvotes: 1
Views: 877
Reputation: 6548
You are right that the problem lies with the version.
coffeescript.org/try uses coffeescript 2.X.X (currently 2.2.4)
Coffeescript 2 compiles down to modern JS as supported by Node 7.6+ This means that Coffeescript classes now compile to ES6 style classes rather than prototypes. This has brought some limitations resulting in changes in Coffeescript 2.
From the coffeescript 2 announcement :
In CoffeeScript 2, “bare” super (calling super without arguments) is now no longer allowed, and one must use super() or super arguments... instead.
You need to change super
to explicitly pass all the arguments to the overwritten method : super arguments...
class p
check: (x,y,z) ->
if x and y
super arguments...
else
if y
x = y
else
super arguments...
Upvotes: 2
Reputation: 2264
It was due to versions of coffee-script.
In http://coffeescript.org/, it has the latest version,
while in http://js2.coffee/, it has version 1.9.2
when I downgrade the version, I was able to resolve my problem.
For current requirement, I have downgraded it and it is the solution to my Problem.
If anyone has a different answer please post your answer.
Thanks
Upvotes: 0