-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expected at least x arguments, but got x or more #28010
Comments
Well that’s kind of a nasty bug. Seems like the spread operator is tripping it up somehow. Possibly a bad interaction between using a spread at the call site and a rest parameter in the declaration? |
Definitely some bugs with interpreting spread, even without using rest in the function:
Though these don't have a critical impact since they are correct errors, just incorrect error messages, unlike the top bug. Perhaps related though. |
Based on #26350 it seems that the underlying issue is that the compiler balks when a spread potentially crosses a formal argument boundary (which will always be the case if it’s not in tail position and the thing being spreaded is anything other than a 1-tuple). |
So there's two things here: clarifying the error messages for most cases to explain the error better, and possibly improving how spread handles arrays? The last one seems less likely, but the error message improvements should be uncontentious. |
It would be possible to “fix” this case (i.e., not issue errors) only because the type of the fixed parameter ( A better error would be placed on the spread element itself, and convey the general idea of “expected a fixed argument, but got a variable-length spread.” |
best workaround solution is to put a dummy argument unfortunately or retype the input ie. lodash merge |
Fix bugs in ConditionParser; Tests for getSimpleConditionClassByKey; Fix imports; Aliases for Greater and GreaterOrEqual condition; Fix the TypeScript bug (microsoft/TypeScript#28010).
TypeScript Version: 3.2.0-dev.20181019 and 3.1.3
Search Terms: function arguments count, spread, rest
Code
Expected behavior:
No errors
"at least 1" == "1 or more"
Actual behavior:
"at least 1" != "1 or more"
Non logical type error.
Playground Link: here
Related Issues:
#26350
The text was updated successfully, but these errors were encountered: