{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9568","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9568/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9568/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9568/events","html_url":"https://github.com/Microsoft/TypeScript/issues/9568","id":164483327,"number":9568,"title":"Consider allowing users to check for uninitialized values","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":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-08T08:33:40Z","updated_at":"2016-07-08T22:14:35Z","closed_at":null,"body":"```ts\r\nfunction findMax(nums: number[]) {\r\n    let max: number;\r\n    \r\n    for (let n of nums) {\r\n        // Error: Variable 'max' is used before being assigned.\r\n        if (max === undefined || n > max) {\r\n            max = n;\r\n        }\r\n    }\r\n\r\n    return max;\r\n}\r\n```\r\n\r\nIt would be really great if we could let users write this without needing to change `max`'s type to `number | undefined`."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/231485580","html_url":"https://github.com/Microsoft/TypeScript/issues/9568#issuecomment-231485580","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9568","id":231485580,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T22:14:35Z","updated_at":"2016-07-08T22:14:35Z","body":"here is a better sample;\r\n\r\n```ts\r\nfunction test () {\r\n    let max: number;\r\n    if (max === undefined) {\r\n        // max used before assinged\r\n        max = 0;\r\n    }\r\n    return max;\r\n}\r\n```"}}
{"actor":{"display_login":"mhegazy"}}