-
Notifications
You must be signed in to change notification settings - Fork 12.8k
es3/es5 inheritance bug #33023
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Emitted code for "use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var SomeClass = /** @class */ (function (_super) {
__extends(SomeClass, _super);
function SomeClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
return SomeClass;
}(Object));
var instance = new SomeClass();
console.log(instance instanceof SomeClass);
console.log(instance instanceof Object); Changing 12th line from: d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); to d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype); fixes the issue but not exactly sure what Also, it's probably worth mentioning that I only managed to reproduce this bug when extending native |
Oh... I've seen that one before. I thought it was only the case when extending Any idea what is the point of |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
3 similar comments
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
|
TypeScript Version: all versions
Search Terms: es3 es5 inheritance bug
Code
Expected behavior:
For every compilation target desired output is:
Actual behavior:
If the compilation target is set to
es3
ores5
:Playground Link: https://typescript-play.js.org/?target=1#code/MYGwhgzhAEDKD2BbApgYXFayAeAXZAdgCYwDyARgFbLC7QDeAvgFAD0r0okMCK63DFs2DwCEOvGgBeaAWQB3OEjQYIACgCUAbmbDREeCGQA6EPADmayQEsxuMAWDJ4AMyV9V2vWMMmzlmzsHJ1doCmpaDSA
The text was updated successfully, but these errors were encountered: