Skip to content
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

Calling overloaded method on union type #31839

Closed
cojj90 opened this issue Jun 10, 2019 · 2 comments
Closed

Calling overloaded method on union type #31839

cojj90 opened this issue Jun 10, 2019 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@cojj90
Copy link

cojj90 commented Jun 10, 2019

TypeScript Version: 3.6.0-dev.20190608

Search Terms: method overloading on union type

Code
please refer to the playground link below

Expected behavior:
Should be able to call eat method since it matches one of the signature.
On playground link, line 27 should not be marked as error.

Funny thing is, removing line 2 (the un-matching function signature) makes tsc happy.
I've added line 32 to show typescript is happy as long as union type is not used

Actual behavior:
TSC marks it as error (Cannot invoke an expression whose type lacks a call signature.)

Playground Link:
playground link

@cojj90 cojj90 changed the title calling a overloaded method on union type Calling overloaded method on union type Jun 10, 2019
@jack-williams
Copy link
Collaborator

Duplicate that is tracked here: #7294. Unions of call signatures currently do not work for generic signatures.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 13, 2019
@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