How to correctly define private abstract methods in TypeScript?
Here is a simple code:
abstract class Fruit {
name: string;
constructor (name: string) {
this.name = name
}
abstract private hiFrase (): string;
}
class Apple extends Fruit {
isCitrus: boolean;
constructor(name: string, isCitrus: boolean) {
super(name);
this.isCitrus = isCitrus;
}
private hiFrase(): string {
return "Hi! I\'m an aplle and my name is " + this.name + " and I'm " + (isCitrus ? "" : " not ") + "citrus";
}
public sayHi() {
alert(this.hiFrase())
}
}
This code does not work. How to fix it?