Closed

Description
TypeScript Version: 3.8.3
Search Terms:
generic function rest parameters
Code
// A *self-contained* demonstration of the problem follows...
function foo<T extends string | number>(...rest: T[]): T[] {
return rest;
}
foo('a', 1);
Expected behavior:
Should compile without error and infer the return type of foo('a', 1)
to be at least
(string | number)[]
or, better still, more accurately as ("a" | 1)[]
Actual behavior:
src/main.ts:5:10 - error TS2345: Argument of type '1' is not assignable to parameter of type '"a"'.
5 foo('a', 1);
Related Issues:
Looked at #37052 for a clue. The only thing there was a similar error message to mine above but otherwise probably a red herring to say that it's similar.