TS2415
TS2415: Class
PanicSellStrategy<Config>incorrectly extends base classStrategy<Config, StrategyState>. Propertypositionis private in typePanicSellStrategy<Config>but not in typeStrategy<Config, StrategyState>.
Broken Code ❌
class Strategy<Config, StrategyState> {
protected position: number;
}
class PanicSellStrategy<Config> extends Strategy<Config, StrategyState> {
private position: number;
}Solution:
To resolve the TS2415 error, ensure the visibility of the position property in the derived class PanicSellStrategy matches that of the base class Strategy. If the base class has position as protected, the derived class should also declare it as protected or more accessible (not private).
Fixed Code ✔️
class Strategy<Config, StrategyState> {
protected position: number;
}
class PanicSellStrategy<Config> extends Strategy<Config, StrategyState> {
protected position: number; // Adjust visibility to match the base class
}