10000 Tuple suffix associated with rest element in a binding pattern · Issue #2714 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Tuple suffix associated with rest element in a binding pattern #2714
Closed
@JsonFreeman

Description

@JsonFreeman

You could imagine that someone had the following:

var tuple: [string, number] = ["", 0];
var [a, ...b] = tuple;

Right now, a is string, but b is (string | number)[]. This is because the type associated with b is the array of the element type of the incoming array.

But it would be really nice if b was [number], or at least number[]. You should be able to chop off the rest of the elements in the incoming array, and only use those for the type associated with a rest element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0