I'm writing an extension for a web-based texteditor. Because of the class hierarchy, my code gives some strange results.
I've tried moving the "validate" function to the base class but to no avail
class BaseClass{
close(): void {
// Does some stuff
}
save(): void {
// Also does things
}
}
class SubClass extends BaseClass{
close(): void {
this.validate(() => super.close()) // This works as expected
}
save(): void {
this.validate(() => super.save()) // This throws the error: Uncaught TypeError: this.validate is not a function
}
validate(callback: () => void){
// Does some validation, then
if (validationOk) callback()
}
}
The expected result is that both the save and close functions in the SubClass call the validate function without errors.