You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declarefunctionhmm<Aextends[]|[number,string]>(...args: A): void;hmm();// okay, A = []hmm(1,"s");// okay, A = [1, "s"]hmm("what");// no error? A = [] | [number, string] ?
Expected behavior:
Error on hmm("what"). A should be inferred as [string], which does not extend [] | [number, string].
Actual behavior:
No error on hmm("what"). Apparently A is inferred as the constraint type [] | [number, string] despite that not matching the actual argument type.
Related Issues: #24897: introduction of tuples into rest/spread expressions #26110: similar issue with bad or weird inference behavior on rest arguments
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.1.0-dev.20180813
Search Terms:
Tuple rest generic union
Code
Expected behavior:
Error on
hmm("what")
.A
should be inferred as[string]
, which does not extend[] | [number, string]
.Actual behavior:
No error on
hmm("what")
. ApparentlyA
is inferred as the constraint type[] | [number, string]
despite that not matching the actual argument type.Playground Link:
Link
Related Issues:
#24897: introduction of tuples into rest/spread expressions
#26110: similar issue with bad or weird inference behavior on rest arguments
The text was updated successfully, but these errors were encountered: