TS2351

error TS2351: This expression is not constructable. Type ‘EMA‘ has no construct signatures.

Bad Code ❌

RSI.ts
1
2
3
4
5
6
7
export class RSI {
private readonly avgGain: MovingAverage;

constructor(private readonly interval: number, Indicator: EMA) {
this.avgGain = new Indicator(this.interval);
}
}
EMA.ts
1
export class EMA {}

Fixed Code ✔️

RSI.ts
1
2
3
4
5
6
7
export class RSI {
private readonly avgGain: MovingAverage;

constructor(private readonly interval: number, Indicator: typeof EMA) {
this.avgGain = new Indicator(this.interval);
}
}