Skip to content

Tuple types and map #6574

Closed
Closed
@elbarzil

Description

I have a piece of code with many foo[]s that should really be [foo,foo] -- it would be nicer if map had a type that preserves tuples, so something like this:

var x: [number, number];
x = [1,2].map(x=>x+1);

would work, even if it's some hack with a union of tuples up to some number of elements (I think that I saw something like that around rest arguments, and I imagine that this in a close neighborhood).

I thought that this would be common, but didn't find anything about it. Feel free to dismiss if it is.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions