Skip to content

Confusing error message when calling value whose type is a union of types with call signatures #5640

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
DanielRosenwasser opened this issue Nov 12, 2015 · 1 comment
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

From @StrahilKazlachev on Gitter on November 12, 2015 9:04 AM

interface MyType {
    x;y;z;
}

function transform(items: MyType[] | string[]) {
    return items.map(val => val);
        // ~~~~~~~~~~~~~~~~~~~~~ Cannot invoke an expression whose type lacks a call signature.
}

We should consider giving a more helpful error message if the type is a union, all of whose types have call signatures. Something like

Cannot invoke an expression whose type is a union with incompatible call signatures.

or hopefully something better than that

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Nov 12, 2015
@mhegazy mhegazy added this to the Community milestone Nov 13, 2015
@mhegazy mhegazy added the Help Wanted You can do this label Nov 13, 2015
@DanielRosenwasser DanielRosenwasser added the Good First Issue Well scoped, documented and has the green light label Nov 18, 2015
erictsangx added a commit to erictsangx/TypeScript that referenced this issue Nov 24, 2015
… union of types with call signatures

add diagnostic message 2658: Cannot invoke an expression whose type is a union with incompatible call signatures.

Closes microsoft#5640
erictsangx added a commit to erictsangx/TypeScript that referenced this issue Nov 26, 2015
… union of types with call signatures

add diagnostic message 2658: Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.

Closes microsoft#5640
erictsangx added a commit to erictsangx/TypeScript that referenced this issue Dec 2, 2015
… union of types with call signatures

add diagnostic message 2658: Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.

Closes microsoft#5640
@zbjornson
Copy link

This message seems to have just manifested after upgrading to 2.1.0-dev.20160729. Glad to find the translation in this issue :).

@mhegazy mhegazy removed this from the Community milestone Apr 26, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants