-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inheritance problem with ES6 class transpiled with BabelJS #12059
Comments
The problem is that, while
For some reason, in your "BabelJS transpiled BaseClass and TypeScript inheritance behavior", the |
Will this be something that eventually gets fixed so we don't need to use (http://babeljs.io/docs/plugins/transform-es2015-classes/)? |
I just ran into what I believe to be the same problem. While this test case works fine, if you make class A {}
Object.defineProperty(A, 'foo', {
get: function() {
return 1;
}
})
class B extends A {}
console.log(B.foo); TypeScript compiled code outputs As @Kovensky mentioned, this is because Babel sets up a prototype chain on the constructor functions themselves as well as the instances, while TypeScript just copies over enumerable properties. |
Haha, yeah I literally just saw that as well while checking before making the change myself. I was just pulling master to test it locally. Pretty sure this can be closed now! EDIT: Yup, worked locally for my test case. Thanks! |
TypeScript Version: 2.0.7
TypeScript seems not correctly inherit static properties from a class transpiled with BabelJS
Code
Expected behavior:
The comparison is falsy.
Actual behavior:
If BaseClass is transpiled via BabelJS the comparison is falsy.
Pure TypeScript behavior:
BabelJS transpiled BaseClass and TypeScript inheritance behavior:
TypeScript transpiled BaseClass and BabelJS inheritance behavior:
The problem is not reproduced in the other side, BabelJS correctly inherit static properties from a class transpiled via TypeScript
The text was updated successfully, but these errors were encountered: