Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improve error message for overload that takes spread arguments#42459

Merged
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
Feb 11, 2021
Merged

Improve error message for overload that takes spread arguments#42459
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

@uraway

@uraway uraway commented Jan 22, 2021

Copy link
Copy Markdown
Contributor

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 #42418

playground

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jan 22, 2021
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you lost coverage. Maybe make the new overload take 8 arguments instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks @DanielRosenwasser
I force-pushed a new commit and updated my comment above.

@uraway uraway force-pushed the improve-error-message-for-overloads branch from 4c2127f to 3a429b0 Compare January 26, 2021 10:54
@sandersn sandersn requested a review from elibarzilay February 8, 2021 23:56
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
@elibarzilay elibarzilay force-pushed the improve-error-message-for-overloads branch from 3a429b0 to a62bb1e Compare February 11, 2021 21:24
@elibarzilay elibarzilay changed the title improve error message for overload that takes spread arguments Improve error message for overload that takes spread arguments Feb 11, 2021
@elibarzilay elibarzilay merged commit a3ead92 into microsoft:master Feb 11, 2021
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.