knockout-es6
knockout-es6 copied to clipboard
accessing this before calling super()
I found some error which will work with available transpilers, but is not valid ES6: accessing this before calling super() will throw a ReferenceError as this will not yet be initialized. You should think about refactoring the property import to a utility function.
constructor(){
this.firstName = 'Planet'; // ReferenceError
this.lastName = 'Earth';
super();
}
Yes, the spec has changed since I made this example. There needs to be a new method added to the base that can be called at the end of the constructor, something like this:
constructor(){
super();
this.firstName = 'Planet'; // ReferenceError
this.lastName = 'Earth';
this.knockout();
}
I wanted to wait until the ES6 extend spec was finalized before looking into this again. But if you are getting issues with transpilers that probably means they have changed to follow the new spec. What transpiler did you test it with?
I meant it does work with transpilers, though it isn't valid ES6... Might be misleading to some as I wasn't aware of this myself when following your example.
aha, ok. Transpilers will probably update their implementation to match the spec soon. I'll see if I can get some time to look into this later on.