{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10442","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10442/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10442/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10442/events","html_url":"https://github.com/Microsoft/TypeScript/issues/10442","id":172237050,"node_id":"MDU6SXNzdWUxNzIyMzcwNTA=","number":10442,"title":"probable bug in typeof type guard","user":{"login":"opensrcken","id":11646382,"node_id":"MDQ6VXNlcjExNjQ2Mzgy","avatar_url":"https://avatars3.githubusercontent.com/u/11646382?v=4","gravatar_id":"","url":"https://api.github.com/users/opensrcken","html_url":"https://github.com/opensrcken","followers_url":"https://api.github.com/users/opensrcken/followers","following_url":"https://api.github.com/users/opensrcken/following{/other_user}","gists_url":"https://api.github.com/users/opensrcken/gists{/gist_id}","starred_url":"https://api.github.com/users/opensrcken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensrcken/subscriptions","organizations_url":"https://api.github.com/users/opensrcken/orgs","repos_url":"https://api.github.com/users/opensrcken/repos","events_url":"https://api.github.com/users/opensrcken/events{/privacy}","received_events_url":"https://api.github.com/users/opensrcken/received_events","type":"User","site_admin":false},"labels":[{"id":113970366,"node_id":"MDU6TGFiZWwxMTM5NzAzNjY=","url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":{"login":"sandersn","id":293473,"node_id":"MDQ6VXNlcjI5MzQ3Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/293473?v=4","gravatar_id":"","url":"https://api.github.com/users/sandersn","html_url":"https://github.com/sandersn","followers_url":"https://api.github.com/users/sandersn/followers","following_url":"https://api.github.com/users/sandersn/following{/other_user}","gists_url":"https://api.github.com/users/sandersn/gists{/gist_id}","starred_url":"https://api.github.com/users/sandersn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandersn/subscriptions","organizations_url":"https://api.github.com/users/sandersn/orgs","repos_url":"https://api.github.com/users/sandersn/repos","events_url":"https://api.github.com/users/sandersn/events{/privacy}","received_events_url":"https://api.github.com/users/sandersn/received_events","type":"User","site_admin":false},"assignees":[{"login":"sandersn","id":293473,"node_id":"MDQ6VXNlcjI5MzQ3Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/293473?v=4","gravatar_id":"","url":"https://api.github.com/users/sandersn","html_url":"https://github.com/sandersn","followers_url":"https://api.github.com/users/sandersn/followers","following_url":"https://api.github.com/users/sandersn/following{/other_user}","gists_url":"https://api.github.com/users/sandersn/gists{/gist_id}","starred_url":"https://api.github.com/users/sandersn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandersn/subscriptions","organizations_url":"https://api.github.com/users/sandersn/orgs","repos_url":"https://api.github.com/users/sandersn/repos","events_url":"https://api.github.com/users/sandersn/events{/privacy}","received_events_url":"https://api.github.com/users/sandersn/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/29","html_url":"https://github.com/Microsoft/TypeScript/milestone/29","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/29/labels","id":1973940,"node_id":"MDk6TWlsZXN0b25lMTk3Mzk0MA==","number":29,"title":"Future","description":"","creator":{"login":"mhegazy","id":8000722,"node_id":"MDQ6VXNlcjgwMDA3MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/8000722?v=4","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},"open_issues":474,"closed_issues":19,"state":"open","created_at":"2016-08-31T00:21:08Z","updated_at":"2018-10-01T22:32:11Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2016-08-19T23:12:16Z","updated_at":"2018-10-02T15:49:55Z","closed_at":null,"author_association":"NONE","body":"**TypeScript Version:**  1.8.0\n\n**Code**\n\n``` ts\nconst numbers: {[key: string]: number} = {a: 1, b: 2};\n\nconst mixed: {[key: string]: number|string} = {a: 1, b: 'two'};\n\nfunction test(something: {[key: string]: number|string}) {\n  Object.keys(something).forEach(k => {\n        if (typeof something[k] === 'number') {\n            Math.floor(something[k]);\n        } else {\n            something[k].toLowerCase();\n        }\n  });\n}\n\ntest(numbers);\n```\n\nLink: https://www.typescriptlang.org/play/#src=const%20numbers%3A%20%7B%5Bkey%3A%20string%5D%3A%20number%7D%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%3B%0D%0A%0D%0Aconst%20mixed%3A%20%7B%5Bkey%3A%20string%5D%3A%20number%7Cstring%7D%20%3D%20%7Ba%3A%201%2C%20b%3A%20'two'%7D%3B%0D%0A%0D%0Afunction%20test(something%3A%20%7B%5Bkey%3A%20string%5D%3A%20number%7Cstring%7D)%20%7B%0D%0A%20%20Object.keys(something).forEach(k%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20if%20(typeof%20something%5Bk%5D%20%3D%3D%3D%20'number')%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20Math.floor(something%5Bk%5D)%3B%0D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20something%5Bk%5D.toLowerCase()%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%7D)%3B%0D%0A%7D%0D%0A%0D%0Atest(numbers)%3B\n\n**Expected behavior:**\nType guard would apply to `something[k]`.\n\n**Actual behavior:** \nType guard does not get applied to `something[k]`.\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/426326425","html_url":"https://github.com/Microsoft/TypeScript/issues/10442#issuecomment-426326425","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10442","id":426326425,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjMyNjQyNQ==","user":{"login":"swashata","id":1623381,"node_id":"MDQ6VXNlcjE2MjMzODE=","avatar_url":"https://avatars1.githubusercontent.com/u/1623381?v=4","gravatar_id":"","url":"https://api.github.com/users/swashata","html_url":"https://github.com/swashata","followers_url":"https://api.github.com/users/swashata/followers","following_url":"https://api.github.com/users/swashata/following{/other_user}","gists_url":"https://api.github.com/users/swashata/gists{/gist_id}","starred_url":"https://api.github.com/users/swashata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swashata/subscriptions","organizations_url":"https://api.github.com/users/swashata/orgs","repos_url":"https://api.github.com/users/swashata/repos","events_url":"https://api.github.com/users/swashata/events{/privacy}","received_events_url":"https://api.github.com/users/swashata/received_events","type":"User","site_admin":false},"created_at":"2018-10-02T15:49:55Z","updated_at":"2018-10-02T15:49:55Z","author_association":"NONE","body":"Thanks @RyanCavanaugh \tfor your response 😄. This is exactly what I did (as you can see in the second part of the code).\r\n\r\nBdw, do you think documenting this behavior somewhere would help newbies like me? If so, anyplace where I can send a PR?"}}
{"actor":{"display_login":"swashata"}}