-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
hixio-mh/TypeScript
#5Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.1.5
Code
abstract class Base {
public constructor(protected el: Element) {
el.addEventListener("click", this.onClick);
}
protected onClick = (): void => {
console.log("Base click");
}
}
class Child extends Base {
protected onClick = (): void => {
console.log("Child click");
}
}
const widget = new Child(document.getElementById("el"));
Expected behavior:
Child click
in console after a click
Actual behavior:
Base click
Why
Compiled JS:
var Child = (function (_super) {
__extends(Child, _super);
function Child() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.onClick = function () {
console.log("Child click");
};
return _this;
}
return Child;
}(Base));
Method onClick
of Child
defined after _super.apply()
.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
RyanCavanaugh commentedon Feb 2, 2017
See #1617