-
Notifications
You must be signed in to change notification settings - Fork 262
@autobind doesn't work properly when calling super from the parent's parent (and probably higher up). #69
Comments
@JabX hmmm I actually can't reproduce this one. I've added an additional test case with your code and it works as expected: #70 Can you confirm you're using one of the latest versions? |
@JabX there were fairly recent changes to the If you are indeed using the latest and it still is happening, can you let me know if you're using any babel transforms? For example, react-hot-loader does naughty things and doesn't work with autobind #48 |
Yup sorry about not mentioning the version, but I'm using 0.12.0 I just tried your test on my setup and it fails, returning |
@JabX just to clarify, you're using TypeScript and not Babel, correct? That very likely the issue. I'll play around a bit and see if I can find how TypeScript is doing things differently. |
Yes that is correct. I was using Babel until recently and I'm pretty sure it transpiles classes in a very different way (to be more accurate to the ES6 spec) with loose mode off (which is the default). |
catch another prototype.key case for autobind, fixes #69
@JabX phew! I believe I've solved the issue and published it as Please confirm. For the curious, TypeScript does indeed transpile classes differently and in a very non-compliant way to the ES2015 (ES6) spec when it comes to That being said this actually revealed a bug in e.g. class A {
get method() {
return () => {};
}
}
class B extends A {}
A.prototype.method;
// this was handled correctly
B.prototype.method;
// but this was not, because `method` is up the chain |
Wow, you already fixed it, you're definitely awesome man! EDIT : Fixed! |
So glad. Cheers! |
In that case, calling
new C().method()
logsundefined
instead of 'hello'. Adding amethod()
definition to B (that callssuper.method()
) solves the problem and I'd rather not have to this. I understand this is an edge case (even more so than regularsuper
calls that were pretty hard to solve from what I hear), but nonetheless, this isn't the expected behaviour.The text was updated successfully, but these errors were encountered: