Whenever I use the spread operator such as below
public drawTextTest(p1: number, p2: number, p3: number):void {
console.log(p1, p2, p3);
}
let array = [2, 2, 5];
this.drawTextTest( ... array );
I get this error in the editor
[ts] Expected # arguments, but got a minimum of 0.
Why does TypeScript give an error when using the spread operator to pass arguments?
There's no error when I actually run the code, the spread operator is simply letting me use the array as arguments to a function yet in VSCode it shows me the error as if I couldn't.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…