TS2511

error TS2511: Cannot create an instance of an abstract class.

Bad Code ❌

1
2
3
myFunction = (strategyConstructor: typeof Strategy, config: StrategyConfig): Promise<Big> => {
// ....
}

Fixed Code ✔️

1
2
3
4
5
export interface Type<T> extends Function { new (...args: any[]): T; }

myFunction = (strategyConstructor: StrategyType<Strategy<StrategyConfig>>, config: StrategyConfig): Promise<Big> => {
// ....
}

Read more: Passing a class constructor as parameter to a function.