Skip to content

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

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions