{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/2174","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/2174/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/2174/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/2174/events","html_url":"https://github.com/facebook/flow/issues/2174","id":168866000,"number":2174,"title":"Potential for better map support in Object.values / Object.entries?","user":{"login":"motiz88","id":2246565,"avatar_url":"https://avatars.githubusercontent.com/u/2246565?v=3","gravatar_id":"","url":"https://api.github.com/users/motiz88","html_url":"https://github.com/motiz88","followers_url":"https://api.github.com/users/motiz88/followers","following_url":"https://api.github.com/users/motiz88/following{/other_user}","gists_url":"https://api.github.com/users/motiz88/gists{/gist_id}","starred_url":"https://api.github.com/users/motiz88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motiz88/subscriptions","organizations_url":"https://api.github.com/users/motiz88/orgs","repos_url":"https://api.github.com/users/motiz88/repos","events_url":"https://api.github.com/users/motiz88/events{/privacy}","received_events_url":"https://api.github.com/users/motiz88/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-02T11:48:53Z","updated_at":"2016-08-02T11:48:53Z","closed_at":null,"body":"What we have today:\r\n```javascript\r\n// in Object:\r\nstatic entries(object: any): Array<[string, mixed]>;\r\nstatic values(object: any): Array<mixed>;\r\n// ...\r\nlet o: {[key: string]: number};\r\n// ...\r\nfor (const v of Object.values(o)) {\r\n  console.log(Math.abs(v));\r\n//                     ^ v: mixed, incompatible with number\r\n}\r\n```\r\n\r\nWhat _may_ be better in the special case where `object` is used strictly as a map:\r\n(Note: I'm being deliberately cautious, which is also why this is not a PR :smile:)\r\n```javascript\r\nstatic values<T>(object: {[key: string]: T}): Array<T>;\r\nstatic entries<T>(object: {[key: string]: T}): Array<[string, T]>;\r\n```\r\n\r\nI tried out these declarations locally over the library ones, and while I was worried about breaking something in the heterogenous case (objects like `{a: 1, b: 'b'}`), Flow actually seemed to infer a valid `T` from whatever I threw at it, and carried on splendidly.\r\n\r\nSo, unless I'm missing something, I think these can become the new declarations of `values` and `entries`. "}}
{"actor":{"display_login":"motiz88"}}