A basic use-case that illustrates what I'm doing:
class Foo {
public constructor(arg1: number, arg2: number) {
console.log(arg1);
console.log(arg2);
}
}
function foo(test: number): number[] {
let args: number[] = [];
for (let i = 0; i < 2; i++) {
args.push(i);
}
if (args.length !== 2) {
throw new Error('Invalid argument length');
}
return new Foo(...args);
}
console.log(foo(1));
When trying to run this, I get:
error TS2556: Expected 2 arguments, but got 0 or more.
16 return new Foo(...args);
Which I'm absolutely unable sure where to go to fix this.