I have this example function:
const spreadingArray(arg1, arg2){ return arg1 + arg2; } const numbers = [4,5]; spreadArray(...numbers); // return 9 spreadArray.apply(this, numbers); // return 9 spreadArray(4, 5); // return 9 This three examples of function should return the same result. But I have an error running ng serve:
TS2556: Expected 2 arguments, but got 0 or more.
If I comment the first spreadArray(...numbers) and run ng serve it compiles fine, I remove the comment again and it automatically recompile with error but it's already compiled so it keep running and the code works. That make me thing that it's a syntactic error because at the end angular knows how to compiled to es5 wish is .apply(this, numbers) in this case. Note: The problem here is not why I should use spread operator, is why TypeScript doesn't understand it. I want to use it because it's just a Javascript ES6 thing. I'm using @angular/cli 6.1.5, @angular 6.1.4 and I've tasted with node 8.10 and 9.11 and typescript 2.7.2 and 2.9.2.
UPDATE: a real example of this ... function: enter image description here