{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23937","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23937/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23937/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/23937/events","html_url":"https://github.com/Microsoft/TypeScript/issues/23937","id":320919220,"number":23937,"title":"Does not narrow variable type when checking \"in\" enum","user":{"login":"samijaber","id":1393142,"avatar_url":"https://avatars2.githubusercontent.com/u/1393142?v=4","gravatar_id":"","url":"https://api.github.com/users/samijaber","html_url":"https://github.com/samijaber","followers_url":"https://api.github.com/users/samijaber/followers","following_url":"https://api.github.com/users/samijaber/following{/other_user}","gists_url":"https://api.github.com/users/samijaber/gists{/gist_id}","starred_url":"https://api.github.com/users/samijaber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samijaber/subscriptions","organizations_url":"https://api.github.com/users/samijaber/orgs","repos_url":"https://api.github.com/users/samijaber/repos","events_url":"https://api.github.com/users/samijaber/events{/privacy}","received_events_url":"https://api.github.com/users/samijaber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-07T19:06:07Z","updated_at":"2018-05-07T19:06:07Z","closed_at":null,"author_association":"NONE","body":"**TypeScript Version:**  2.8.3\r\n\r\n**Search Terms:** \r\nenum, \"in\", string equivalence, type narrowing\r\n\r\n**Code**\r\n```ts\r\nenum SomeEnum {\r\n    a = 'a',\r\n    b = 'b',\r\n    c = 'c'\r\n};\r\n\r\n\r\nconst fn = (str: string) => {\r\n    if (str in SomeEnum) {\r\n        const enumVal = str;\r\n    }\r\n} \r\n```\r\n\r\n**Expected behavior:**\r\n`enumVal` to have type `SomeEnum`\r\n\r\n**Actual behavior:**\r\n`enumVal` has type `string`\r\n\r\n**Playground Link:** https://www.typescriptlang.org/play/index.html#src=enum%20SomeEnum%20%7B%0D%0A%20%20%20%20a%20%3D%20'a'%2C%0D%0A%20%20%20%20b%20%3D%20'b'%2C%0D%0A%20%20%20%20c%20%3D%20'c'%0D%0A%7D%3B%0D%0A%0D%0A%0D%0Aconst%20fn%20%3D%20(str%3A%20string)%20%3D%3E%20%7B%0D%0A%20%20%20%20if%20(str%20in%20SomeEnum)%20%7B%0D%0A%20%20%20%20%20%20%20%20const%20enumVal%20%3D%20str%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%20\r\n"}}
{"actor":{"display_login":"samijaber"}}