Open ever-null opened 9 years ago
this should be doable:
this
within a class constructor declaration scope as a temp varthis
variable is undefinedshould work just fine, maybe
I've also tested it without the lambda expecting the delegate to be called using fn.call(...) and this also raises the error:
class Bar extends Foo {
constructor() {
super(function() {
// Expecting `this` to come from superclass call of fn.call(this, ...args).
this.doSomething();
});
}
doSomething() { }
}
I would think this scenario would be allowed given the context of this could come from anywhere then.
Right now we only do static checking for this
in constructors. We would
have to combine that with a runtime check in these kind of situations.
On Sun, May 10, 2015 at 9:13 AM, hayesmg notifications@github.com wrote:
I've also tested it without the lambda expecting the delegate to be called using fn.call(...) and this also raises the error:
class Bar extends Foo { constructor() { super(function() { // Expecting
this
to come from superclass call of fn.call(this, ...args). this.doSomething(); }); }doSomething() { } }
— Reply to this email directly or view it on GitHub https://github.com/google/traceur-compiler/issues/1930#issuecomment-100639684 .
erik
@arv Thanks for the reply. I'm guessing this might be enough of an edge case that you guys won't consider implementing it? I suppose I could use 0.0.85 or introduce a method that is called after super that initializes the superclass' internal state.
I am attempting to pass a function to the superclass and receiving the "this is not allowed before super()" error. Is it possible to have it not inspect this when it is wrapped in a delegate?