Here is the simple code. I need to use arrow function hello() for reasons in the child class.
The code throws an error when I call the.greeting() in the constructor of the parent class:
index.ts:29 Uncaught TypeError: this.hello is not a function at Child.greeting ...
However, the problem does not occur when I use the regular function, but I must use the arrow function.
Please tell me what the problem is and how to fix it.
abstract class Parent{
constructor(){
this.greeting();
}
abstract hello();
greeting(){
this.hello();
}
}
class Child extends Parent{
hello = ()=>{
console.log('hello there');
}
}
const child = new Child();