Skip to content

Confusing type error message in concat #6594

Closed
@elbarzil

Description

@elbarzil

Typechecking this code:

var x: string[] = ["A","B","C"];
x = x.concat([1,2,3])

will throw up with

Argument of type 'number[]' is not assignable to parameter of type 'string'.

This happens even without the x = assignment, and that shows that it would make more sense if the error was either of:

Argument of type 'number' is not assignable to parameter of type 'string'.

or

Argument of type 'number[]' is not assignable to parameter of type 'string[]'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions