This my parent class, it has trigger method which is public method:
class BaseEffect {
//properties and contructor...
//other methods...
public trigger = (): void => void (this.target.hitPoint -= this.amount);
}
And a TurnBasedEffect extends BaseEffect class:
class TurnBasedEffect extends BaseEffect {
//properties and contructor...
//other methods...
public trigger = (): void => {
super.trigger();
this.remainingTurns--;
};
}
This class also has trigger method, inside this method, a trigger method of the parent class is called.
The problem is when a trigger method of the derived class is called, typescript throws this error:
TypeError: (intermediate value).trigger is not a function
And point to this line of the trigger method of the TurnBasedEffect class:
//...
super.trigger();
//...
What's wrong with my classes and how to solve this problem?