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
{{ message }}
Repository navigation
Generic parameters constrained to unions of tuples are not inferred correctly in rest parameter positions #26491
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
Activity
RyanCavanaugh commentedon Aug 16, 2018
Anders Hejlsberg (@ahejlsberg) I'm probably missing something here but this seems bad