TS2428
All declarations of 'Strategy' must have identical type parameters.
Broken Code ❌
enum TOPIC {
ON_LOGOUT = 'ON_LOGOUT',
}
export interface Strategy {
on(event: TOPIC.ON_LOGOUT, listener: (reason: string) => void): this;
}
export abstract class Strategy<SpecificConfig extends StrategyConfig> extends EventEmitter {
// ...
}Fixed Code ✔️
Solution: The generic abstract class Strategy has a generic type parameter list in angle brackets (diamond notation). This generic type parameter list must also be added to the interface definition of Strategy.
enum TOPIC {
ON_LOGOUT = 'ON_LOGOUT',
}
export interface Strategy<SpecificConfig extends StrategyConfig> {
on(event: TOPIC.ON_LOGOUT, listener: (reason: string) => void): this;
}
export abstract class Strategy<SpecificConfig extends StrategyConfig> extends EventEmitter {
// ...
}