{"action":"created","issue":{"url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/59","labels_url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/59/comments","events_url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/59/events","html_url":"https://github.com/codemix/babel-plugin-typecheck/issues/59","id":118582159,"number":59,"title":"Type annotation in loop","user":{"login":"sgodwin424","id":5580662,"avatar_url":"https://avatars.githubusercontent.com/u/5580662?v=3","gravatar_id":"","url":"https://api.github.com/users/sgodwin424","html_url":"https://github.com/sgodwin424","followers_url":"https://api.github.com/users/sgodwin424/followers","following_url":"https://api.github.com/users/sgodwin424/following{/other_user}","gists_url":"https://api.github.com/users/sgodwin424/gists{/gist_id}","starred_url":"https://api.github.com/users/sgodwin424/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgodwin424/subscriptions","organizations_url":"https://api.github.com/users/sgodwin424/orgs","repos_url":"https://api.github.com/users/sgodwin424/repos","events_url":"https://api.github.com/users/sgodwin424/events{/privacy}","received_events_url":"https://api.github.com/users/sgodwin424/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-24T10:58:23Z","updated_at":"2015-11-26T10:56:10Z","closed_at":"2015-11-24T22:23:01Z","body":"In the following example:\r\n\r\n```js\r\nlet foo: Array<string> = [ ];\r\n\r\nfor (let bar: string of foo)\r\n{\r\n    // ...\r\n}\r\n\r\n```\r\n\r\nI get a runtime error that bar violates its contract as it `expected string got undefined`. This only happens when foo is an empty array, but it seems a bit silly for this to occur. Running the same code through Flowtype does not produce a warning or error.\r\n\r\nIt is easy enough to just use `?string` but this requires an additional null/undefined check before using `bar` so that Flowtype will not complain about it as well. "},"comment":{"url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/comments/159878321","html_url":"https://github.com/codemix/babel-plugin-typecheck/issues/59#issuecomment-159878321","issue_url":"https://api.github.com/repos/codemix/babel-plugin-typecheck/issues/59","id":159878321,"user":{"login":"sgodwin424","id":5580662,"avatar_url":"https://avatars.githubusercontent.com/u/5580662?v=3","gravatar_id":"","url":"https://api.github.com/users/sgodwin424","html_url":"https://github.com/sgodwin424","followers_url":"https://api.github.com/users/sgodwin424/followers","following_url":"https://api.github.com/users/sgodwin424/following{/other_user}","gists_url":"https://api.github.com/users/sgodwin424/gists{/gist_id}","starred_url":"https://api.github.com/users/sgodwin424/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgodwin424/subscriptions","organizations_url":"https://api.github.com/users/sgodwin424/orgs","repos_url":"https://api.github.com/users/sgodwin424/repos","events_url":"https://api.github.com/users/sgodwin424/events{/privacy}","received_events_url":"https://api.github.com/users/sgodwin424/received_events","type":"User","site_admin":false},"created_at":"2015-11-26T10:56:10Z","updated_at":"2015-11-26T10:56:10Z","body":"I have a case such as the following:\r\n\r\n```js\r\nlet foo: Array<string|Type> = [ ];\r\n\r\nfor (let bar: string|Type of foo)\r\n{\r\n    // ...\r\n}\r\n```\r\n\r\nWhere I receive the same error as before. I will take a look after Thanksgiving if you haven't gotten around to looking at it.\r\n\r\nThanks for the great plugin!"}}