Description
Assume
class B {}
class C extends B {}
The default __extends
is copying each own property of B
to C
. This is a problem because it means that a property of B
becomes indistinguishable from a property of C
(by virtue of copy, it is its own).
This doesn't seem like much, but sometimes you need each class to have a different value for a property.
For a real life use-case, I was bitten here: aurelia/metadata#22.
Other use-cases that occured to me because of this bug: WeakMap
polyfills stores data in the object under a random key. Because of the codegen above, WeakMap
doesn't work properly for B
and C
.
By virtue of that, Reflect.metadata
polyfill is not working in IE9 and 10 (it relies on WeakMap
).
Contrast with Babel, who just chains prototype
. This way, one can check hasOwnProperty()
.
An artificial example showing the different behavior between TS and Babel: