Inference fails for type argument for two arguments with unions #8879
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
TypeScript Version:
nightly (1.9.0-dev.20160528-1.0)
Code
A generic that is used twice in the argument list cannot always be resolved when a union type is used.
Expected behavior:
No errors,
U
would be resolved asnumber
andT
as{ x: boolean }
Actual behavior:
These errors:
As a work around I can use two type arguments and take the union of them (
foo2<T, V>(xs: (T | string)[], ys: (V | string)[]): (T | V)[]
), but that doesn't look pretty and I got some issues with an empty array (#8878).The text was updated successfully, but these errors were encountered: