{"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10238","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10238/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10238/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10238/events","html_url":"https://github.com/Microsoft/TypeScript/issues/10238","id":170289115,"number":10238,"title":"Inconsistent inference between optional parameter taking Iterable and Array","user":{"login":"DanielRosenwasser","id":972891,"avatar_url":"https://avatars.githubusercontent.com/u/972891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielRosenwasser","html_url":"https://github.com/DanielRosenwasser","followers_url":"https://api.github.com/users/DanielRosenwasser/followers","following_url":"https://api.github.com/users/DanielRosenwasser/following{/other_user}","gists_url":"https://api.github.com/users/DanielRosenwasser/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielRosenwasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielRosenwasser/subscriptions","organizations_url":"https://api.github.com/users/DanielRosenwasser/orgs","repos_url":"https://api.github.com/users/DanielRosenwasser/repos","events_url":"https://api.github.com/users/DanielRosenwasser/events{/privacy}","received_events_url":"https://api.github.com/users/DanielRosenwasser/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-09T22:46:42Z","updated_at":"2016-09-22T05:00:01Z","closed_at":"2016-09-22T05:00:01Z","body":"Consider the following:\r\n\r\n```ts\r\ndeclare class KV_Array<K,V> {    \r\n    constructor(entries?: [[K, V]]);\r\n}\r\nconst mapFromArray = new KV_Array([\r\n    [\"a\", 1],\r\n    [\"b\", 2],\r\n    [\"c\", 3],\r\n]);\r\n```\r\n\r\nThe above works as expected. `mapFromArray` has the type `KV_Array<string, number>`.\r\n\r\nNow take this sample which instead makes its parameter `Iterable` instead of just an `Array`.\r\n\r\n```ts\r\ndeclare class KV_Iterable<K,V> {    \r\n    constructor(entries?: Iterable<[K, V]>);\r\n}\r\nconst mapFromIter = new KV_Iterable([\r\n    [\"a\", 1],\r\n    [\"b\", 2],\r\n    [\"c\", 3],\r\n]);\r\n```\r\n\r\nThis actually *doesn't* work!\r\n\r\nNote that if you make the parameter non-optional in `KV_Iterable`, you will get the desirable result."}}
{"actor":{"display_login":"mhegazy"}}