I wrote the following code:
export class ClickHandlers {
static entityNameClickHandler(id) {
console.log("EntityNameClickHandler");
// add the new subTree to the end of historySubTree
this.history.addToHistory(id);
this.refreshEntityContentElem(this);
}
}
in another file:
addEventListenersToEntityInExplorer(elem, id) {
elem.find('[data-id ^= "expand_"]').click(ClickHandlers.expandButtonHandler);
elem.find('[data-id ^= "entity"]').click(function() {
ClickHandlers.entityNameClickHandler.call(this, id)
}.bind(this));
}
I get an error for the lines: this.history.addToHistory(id); this.refreshEntityContentElem(this);
The error is:
Error:(25, 12) TS2339:Property 'history' does not exist on type 'typeof ClickHandlers'.
What I understand is that Typescript looks at 'this' as the class ClickHanlders. However, I called function 'ClickHandlers.entityNameClickHandler' using 'call', so 'this' is not necessarily the wrapping object.