Skip to content

Bad error message for assigning empty array to tuple type #6524

Closed
@Arnavion

Description

@Arnavion

Reported in the IRC channel against 1.7.5. Still exists in 1.8.0-dev.20160117

var x: [number] = [];
foo.ts(1,5): error TS2322: Type 'undefined[]' is not assignable to type '[number]'.
  Property '0' is missing in type 'undefined[]'.

I guess undefined comes from the fact that the RHS array is empty, so its element type is left uninitialized. Maybe you want to detect that and have a different error message? "An empty array is not assignable to type [number]." or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions