-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
tsc 2.4.1
const keyHandlers = {
'ArrowDown': function (this: SomeComponent, $event) {
// error on accessing private method.
// `this` does not have method private `handleArrowDown`
this.handleArrowDown($event);
}
}
export class SomeComponent {
onKeyDown($event) {
if (typeof keyHandlers[$event.code] === 'function') {
keyHandlers[$event.code].call(this, $event);
}
}
private handleArrowDown(_event) {
// ...
}
}Since the ArrowDown function takes the scope of this as SomeComponent, it is part of the class and should be able to access the private methods.
Origin: #9448 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code