Skip to content

Improve tuple errors #2090

@danquirk

Description

@danquirk
var [x, y] = [1];

The error is on y saying 'Type [number] has no property 1' which is not the most intuitive result. The more human readable explanation would be a span on either the full LHS or full RHS saying 'Tuple type [number] with length 1 cannot be assigned to a tuple type with length 2.'

Another:

var [x, [a,b]] = [[]];

The error is on the inner binding pattern [a,b] saying 'Type [undefined[]] has no property 1'. Again it would be much more understandable to error on the entire LHS or RHS saying 'Tuple type [undefined[]] with length 1 cannot be assigned to tuple type with length 2.'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA 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