TS2370

error TS2370: A rest parameter must be of an array type.

Bad Code ❌

1
2
3
4
5
export interface Indicator<R = Big> {
getResult(): R;

update(...args: R): void;
}

Fixed Code ✔️

A rest parameter allows a function to accept an indefinite number of parameters which why it is impossible to list all their types. That’s why TypeScript requires you to use the any typing for every rest parameter.

1
2
3
4
5
export interface Indicator<R = Big> {
getResult(): R;

update(...args: any): void;
}