{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6574","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6574/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6574/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6574/events","html_url":"https://github.com/Microsoft/TypeScript/issues/6574","id":128212896,"number":6574,"title":"Tuple types and map","user":{"login":"elbarzil","id":16406475,"avatar_url":"https://avatars.githubusercontent.com/u/16406475?v=3","gravatar_id":"","url":"https://api.github.com/users/elbarzil","html_url":"https://github.com/elbarzil","followers_url":"https://api.github.com/users/elbarzil/followers","following_url":"https://api.github.com/users/elbarzil/following{/other_user}","gists_url":"https://api.github.com/users/elbarzil/gists{/gist_id}","starred_url":"https://api.github.com/users/elbarzil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elbarzil/subscriptions","organizations_url":"https://api.github.com/users/elbarzil/orgs","repos_url":"https://api.github.com/users/elbarzil/repos","events_url":"https://api.github.com/users/elbarzil/events{/privacy}","received_events_url":"https://api.github.com/users/elbarzil/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Needs%20Proposal","name":"Needs Proposal","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-22T18:18:58Z","updated_at":"2016-03-27T01:12:06Z","closed_at":null,"body":"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:\r\n\r\n    var x: [number, number];\r\n    x = [1,2].map(x=>x+1);\r\n\r\nwould 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).\r\n\r\nI thought that this would be common, but didn't find anything about it.  Feel free to dismiss if it is.\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/201966520","html_url":"https://github.com/Microsoft/TypeScript/issues/6574#issuecomment-201966520","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6574","id":201966520,"user":{"login":"elibarzilay","id":185905,"avatar_url":"https://avatars.githubusercontent.com/u/185905?v=3","gravatar_id":"","url":"https://api.github.com/users/elibarzilay","html_url":"https://github.com/elibarzilay","followers_url":"https://api.github.com/users/elibarzilay/followers","following_url":"https://api.github.com/users/elibarzilay/following{/other_user}","gists_url":"https://api.github.com/users/elibarzilay/gists{/gist_id}","starred_url":"https://api.github.com/users/elibarzilay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elibarzilay/subscriptions","organizations_url":"https://api.github.com/users/elibarzilay/orgs","repos_url":"https://api.github.com/users/elibarzilay/repos","events_url":"https://api.github.com/users/elibarzilay/events{/privacy}","received_events_url":"https://api.github.com/users/elibarzilay/received_events","type":"User","site_admin":false},"created_at":"2016-03-27T01:12:06Z","updated_at":"2016-03-27T01:12:06Z","body":"@aluanhaddad, sure it does add value!  (Otherwise I wouldn't start this in the first place.)\r\n\r\nConsider a library that deals with 2d points represented as `[x,y]` -- the types should all be a pair of two numbers, and *preserving* that property (by making the typechecker enforce it) adds the value of less chances of bugs.  Should I be allowed to concatenate two such points? `.push()` a new number to a point? `.pop()` one out? etc?  -- Yes, but the result will not be a valid point, unlike `.map()` with a numeric function.\r\n\r\nThat's a classic use of a typechecker like TS, *and* it already has a way to represent this information, it just doesn't get maintained in some places.\r\n"}}