js2coffee / js2coffee

Compile JavaScript to CoffeeScript

Home Page:http://js2.coffee

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recognize defaults in CoffeeScript code when object destructuring is used

pbadenski opened this issue · comments

This is a correct CoffeScript code:

method = ({foo = 2}) -> console.log(foo)

but when used with js2cofee it reports an error: unexpected =

Coffeescript transpiler translates it to the equivalent JavaScript code:

(function() {
  var method;

  method = function(arg) {
    var foo, ref;
    foo = (ref = arg.foo) != null ? ref : 2;
    return console.log(foo);
  };

}).call(this);

I believe js2coffee should match the behavior of a coffeescript transpiler.