Skip to content

Varargs doesn't inherit overloads properly. #41558

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

Closed
Griffork opened this issue Nov 17, 2020 · 3 comments
Closed

Varargs doesn't inherit overloads properly. #41558

Griffork opened this issue Nov 17, 2020 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@Griffork
Copy link

Griffork commented Nov 17, 2020

TypeScript Version:

  • Playground 4.1.0 beta with ESNext types.
  • 3.9.x

Search Terms: ...args, call, typescript, varargs.

Code

type foo = ((val: true, obj: any)=>void) & ((val: false)=>void);
var test!: foo;
test(true, {});
test(false);
test.call(window, true, {}); //This errors, and shouldn't.
test.call(window, false);

Playground Link

Expected behavior:
test.call with 3 arguments doesn't error.

Actual behavior:
test.call with 3 arguments does error, because typescript force-chooses the last overload of an overloaded method.

Related Issues:
This issue is impossible to search for because "...args" and "call" are such generic terms, that a bunch of unrelated issues come up in the search result. I did go looking for duplicates but there is a high possibility that there's a duplicate out there that I wasn't able to find.

@jcalz
Copy link
Contributor

jcalz commented Nov 17, 2020

Duplicate of #38353, putting "overload" in the search term found it for me.

@Griffork
Copy link
Author

Thanks! I didn't try searching for that word on it's own.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Nov 19, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants