Improve error message for overload that takes spread arguments#42459
Merged
elibarzilay merged 1 commit intoFeb 11, 2021
microsoft:mastermicrosoft/TypeScript:masterfrom
uraway:improve-error-message-for-overloadsuraway/TypeScript:improve-error-message-for-overloadsCopy head branch name to clipboard
Merged
Improve error message for overload that takes spread arguments#42459elibarzilay merged 1 commit intomicrosoft:mastermicrosoft/TypeScript:masterfrom uraway:improve-error-message-for-overloadsuraway/TypeScript:improve-error-message-for-overloadsCopy head branch name to clipboard
elibarzilay merged 1 commit into
microsoft:mastermicrosoft/TypeScript:masterfrom
uraway:improve-error-message-for-overloadsuraway/TypeScript:improve-error-message-for-overloadsCopy head branch name to clipboard
Conversation
Comment on lines
38
to
-40
| f2(1, 2, 3, 4, 5, 6, 7); | ||
| ~ | ||
| !!! error TS2554: Expected 0-6 arguments, but got 7. | ||
| No newline at end of file |
Member
There was a problem hiding this comment.
Seems like you lost coverage. Maybe make the new overload take 8 arguments instead?
Contributor
Author
There was a problem hiding this comment.
Oops! Thanks @DanielRosenwasser
I force-pushed a new commit and updated my comment above.
4c2127f to
3a429b0
Compare
The original error message on the last line I have added to in
functionParameterArityMismatch.ts was
No overload expects 5 arguments, but overloads do exist that expect
either 4 or Infinity arguments.
even if we do not define a function that takes Infinity arguments.
This PR changes it to this:
Expected 0-6 arguments, but got 5 or more.
I feel it is still a bit strange but much more understandable.
Fixes microsoft#42418
3a429b0 to
a62bb1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original error message on the last line I have added to in
functionParameterArityMismatch.tswaseven if we do not define a function that takes Infinity arguments.
This PR changes it to this:
I feel it is still a bit strange but much more understandable.
Fixes #42418
playground