assign to `this.param` in prototype method signature
DavidSouther opened this issue · 2 comments
DavidSouther commented
In coffeescript,
class Foo
constructor: ->
@args = []
act: (@args...)->
compiles to
var Foo,
__slice = [].slice;
Foo = (function() {
function Foo() {
this.args = [];
}
Foo.prototype.act = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
this.args = args;
};
return Foo;
})();
Which has the effect of setting this.args
to the passed args array, or using the old value if nothing past.
In Redux, it compiles to
void function () {
Foo = function () {
function Foo() {
this.args = [];
}
Foo.prototype.act = function (this.args) {
this.args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
};
return Foo;
}();
}.call(this);
Notice that the method signature is now this.args
- which is a syntax error in JS.
michaelficarra commented
This is fixed on master
.
// Generated by CoffeeScript 2.0.0-beta9-dev
void function () {
Foo = function () {
function Foo() {
this.args = [];
}
Foo.prototype.act = function () {
this.args = arguments.length > 0 ? [].slice.call(arguments, 0) : [];
};
return Foo;
}();
}.call(this);
DavidSouther commented
Oh, awesome! When will beta9 get released to NPM?