I was wondering why Typescript complains with the following error:
(22,28): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number[]'.
when I use the zip function with the following arguments:
let ranges = ["0-100", "100-200", "200-300", "300-400", "400-500"];
let arrays = [[19.99, 49.99, 49.99, 49.99, 29.99, 29.99, 9.99, 29.99, 34.99, 34.99, 59.99], [149.99, 179.99, 129.99, 149.99, 129.99, 199.99, 129.99], [209.99, 249.99, 292.99, 279.99, 219.99]];
let result = _.zip(ranges, arrays);
However, if I use _.zipObject, the error disappears.
In case it is important, I installed the type information using typings install lodash --save.
UPDATE 2
I think zip doesn't like to receive arguments with different types. In this case, ranges is of type string[] and arrays of type number[].
UPDATE
I was wrong. I changed the values of arrays to use strings, but now I get this slightly different error:
(24,28): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'string[]'.
Maybe there is something related to the nested arrays in the variable arrays?
_.zip<number|string>(...)_.zip. I think that would be an array of arrays.