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

suggestion for improvement of the error message: No overload expects 2 arguments, but overloads do exist that expect either 2 or Infinity arguments. even if there is no definitions that take Infinity argumentsΒ #42418

Copy link
Copy link
@uraway

Description

@uraway
Issue body actions

Bug Report

πŸ”Ž Search Terms

argument count error

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about overload

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare function fn(v1: number): void;
declare function fn(v1: number, v2: number): void;
declare function fn(v1: number, v2: number, v3: number): void;

const arr = [0]
fn(...arr, 1, 2) // No overload expects 2 arguments, but overloads do exist that expect either 2 or Infinity arguments. (2575)

πŸ™ Actual behavior

The error message is

No overload expects 2 arguments, but overloads do exist that expect either 2 or Infinity arguments. (2575)

I understand this part: No overload expects 2 arguments because the first argument is potentially empty.
However, I do not define a function that takes Infinity arguments, though the error message tells so.

πŸ™‚ Expected behavior

The error message should be something like

Expected 1-3 arguments, but got 2 or more.(2556)

since if I use fn like below, TypeScript says Expected 1-3 arguments, but got 1 or more.(2556)

fn(...arr, 1) 
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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