-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
ES6Relates to the ES6 SpecRelates to the ES6 SpecWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it
Milestone
Description
The following should log true
but logs false
instead:
class Foo {}
class Bar extends Foo {}
console.log(Object.getPrototypeOf(Bar) === Foo);
This is due to how the __extends helper is implemented. It generates this:
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
An example of a correctly functioning extends implementation can be found in the 6to5 compiler. Here is their implementation:
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
calebboyd
Metadata
Metadata
Assignees
Labels
ES6Relates to the ES6 SpecRelates to the ES6 SpecWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it