TS2351
error TS2351: This expression is not constructable. Type ‘EMA
‘ has no construct signatures.
Broken Code ❌
RSI.ts1 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.tsFixed Code ✔️
RSI.ts1 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); } }
|