{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/1971","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/1971/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/1971/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/1971/events","html_url":"https://github.com/facebook/flow/issues/1971","id":160997537,"number":1971,"title":"Admits object literals with incompatible types to map when using computed properties","user":{"login":"kholerabbi","id":72674,"avatar_url":"https://avatars.githubusercontent.com/u/72674?v=3","gravatar_id":"","url":"https://api.github.com/users/kholerabbi","html_url":"https://github.com/kholerabbi","followers_url":"https://api.github.com/users/kholerabbi/followers","following_url":"https://api.github.com/users/kholerabbi/following{/other_user}","gists_url":"https://api.github.com/users/kholerabbi/gists{/gist_id}","starred_url":"https://api.github.com/users/kholerabbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kholerabbi/subscriptions","organizations_url":"https://api.github.com/users/kholerabbi/orgs","repos_url":"https://api.github.com/users/kholerabbi/repos","events_url":"https://api.github.com/users/kholerabbi/events{/privacy}","received_events_url":"https://api.github.com/users/kholerabbi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-18T00:32:06Z","updated_at":"2016-06-18T00:32:06Z","closed_at":null,"body":"When using a map type, such as `{[key: string]: number}`, with an object literal that uses computed properties, Flow seems to be failing to detect that the types of the key or value of the object are not compatible with the map type.\r\n\r\n```js\r\n// @flow\r\n\r\ntype Map = {[key: string]: number}\r\n\r\n/* Neither the key or value types are correct, but Flow\r\n * still admits them.\r\n */\r\nconst a: Map = {[0]: \"hello\"};\r\n\r\n/* Same problem.\r\n *\r\n * This is a common scenario in Redux projects, where\r\n * the spread operator is used to make a copy.\r\n *     return {...old, [id]: value}\r\n */\r\nfunction f(): Map {\r\n\treturn {[0]: \"hello\"};\r\n}\r\n\r\n/* This version DOES throw an error, for both\r\n * the key and value, as desired\r\n */\r\nconst b: Map = {};\r\nb[0] = \"hello\";\r\n\r\n/* This also correctly throws an error for the value */\r\nconst c: Map = {[\"0\"]: \"hello\"};\r\n\r\n/* As does this */\r\nconst d: Map = {\"0\": \"hello\"};\r\n\r\n/* But this fails to throw an error */\r\nconst e: Map = {[\"\" + \"0\"]: \"hello\"};\r\n```"}}
{"actor":{"display_login":"kholerabbi"}}