|
|
|
|
|
by jeswin
4035 days ago
|
|
Correct me if I'm wrong, but the necessity for decorators seem to have risen from the ES6 class syntax. If we were doing classes/functions the old imperative style, we could have simply wrapped the RHS in a standard function that does what the decorator does. Animal.prototype.speedup = typeCheckDecorator("number", "number", function(x) {
this.speed += x;
return this.speed;
});
I get that the class syntax makes things easier for people coming from other languages. And maybe makes static analysis easier. But still not sure if it was really needed. |
|