proposal-class-method-parameter-decorators
proposal-class-method-parameter-decorators copied to clipboard
What should the returned function's 'this' be for constructor parameters?
The Anatomy of a parameter decorator section of the README shows "desugarization" for a method, but what about constructors?
Here, I'm simply changing method for constructor, and adding a super class and call to super() in the constructor:
class C extends BC {
constructor(@A param1) {
super(param1);
...
}
}
Following the same "transformation", this should then be roughly equivalent to
var _param1_init
class C extends BC {
static {
_param1_init = A(undefined, { kind: "parameter", name: "param1", index: 0, /*...*/ });
}
constructor(param1) {
// BOOM this breaks, you cannot reference `this` before you call `super()`
// and you can't call super() first as _param1_init wouldn't have been called yet,
// making it useless in many cases.
if (_param1_init !== undefined) param1 = _param1_init.call(this, param1);
super(param1);
...
}
}
Should it then be called with undefined? with C?