{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/935","labels_url":"https://api.github.com/repos/facebook/flow/issues/935/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/935/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/935/events","html_url":"https://github.com/facebook/flow/issues/935","id":110817330,"number":935,"title":"Type of object value not inferred correctly in for-in loop","user":{"login":"chenglou","id":1909539,"avatar_url":"https://avatars.githubusercontent.com/u/1909539?v=3","gravatar_id":"","url":"https://api.github.com/users/chenglou","html_url":"https://github.com/chenglou","followers_url":"https://api.github.com/users/chenglou/followers","following_url":"https://api.github.com/users/chenglou/following{/other_user}","gists_url":"https://api.github.com/users/chenglou/gists{/gist_id}","starred_url":"https://api.github.com/users/chenglou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenglou/subscriptions","organizations_url":"https://api.github.com/users/chenglou/orgs","repos_url":"https://api.github.com/users/chenglou/repos","events_url":"https://api.github.com/users/chenglou/events{/privacy}","received_events_url":"https://api.github.com/users/chenglou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-10T21:15:23Z","updated_at":"2015-10-10T21:59:20Z","closed_at":null,"body":"```js\r\ntype A = {\r\n  a: string,\r\n  b: string,\r\n}\r\n\r\nconst obj: A = {\r\n  a: 'aaa',\r\n  b: 'bbb',\r\n};\r\n\r\nfor (let key in obj) {\r\n  if (!obj.hasOwnProperty(key)) {\r\n    continue;\r\n  }\r\n  const a: number = add(obj[key], 2);\r\n}\r\n```\r\nWhere `add` is `(number, number) => number` (just to highlight the point that it's not `+` operator's fault).\r\n\r\nI guess this is tricky? Because if you define the type of `A.a` as a number then the user probably need to do some complex case matching in the loop to signal what type `obj[key]` is.\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/147128901","html_url":"https://github.com/facebook/flow/issues/935#issuecomment-147128901","issue_url":"https://api.github.com/repos/facebook/flow/issues/935","id":147128901,"user":{"login":"samwgoldman","id":254842,"avatar_url":"https://avatars.githubusercontent.com/u/254842?v=3","gravatar_id":"","url":"https://api.github.com/users/samwgoldman","html_url":"https://github.com/samwgoldman","followers_url":"https://api.github.com/users/samwgoldman/followers","following_url":"https://api.github.com/users/samwgoldman/following{/other_user}","gists_url":"https://api.github.com/users/samwgoldman/gists{/gist_id}","starred_url":"https://api.github.com/users/samwgoldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samwgoldman/subscriptions","organizations_url":"https://api.github.com/users/samwgoldman/orgs","repos_url":"https://api.github.com/users/samwgoldman/repos","events_url":"https://api.github.com/users/samwgoldman/events{/privacy}","received_events_url":"https://api.github.com/users/samwgoldman/received_events","type":"User","site_admin":false},"created_at":"2015-10-10T21:59:20Z","updated_at":"2015-10-10T21:59:20Z","body":"Hrm, well, we could make Flow clever enough to know that `key` is the string literal type `'b'` within that branch. In this case, you could also replace `obj[key]` with `obj['b']`, which has no error."}}