mockdeep / typewiz

Automatically discover and add missing types in your TypeScript code
https://medium.com/@urish/manual-typing-is-no-fun-introducing-typewiz-58e3e8813f4c
1.1k stars 46 forks source link

Don't instrument calls with spread arguments #45

Closed urish closed 6 years ago

urish commented 6 years ago

When instrumentCallExpressions is enabled, we currently instrument calls with spread arguments. This results in an error. For instance, given the following code:

    arr.concat(...values);

the result will look like:

    arr.concat($_$twiz.track(...values,"filename.ts",15));

which is obviously not correct, as now arr.concat() will only get the first element of the array, and $_$twiz.track will get the wrong number of arguments (unless the array only has one element).

Eventually, this can be improved by tracking each of the individual values in the array, perhaps by introducing a new $_$twiz.trackArray() method that will call $_$twiz.track() for each array element.