{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21546","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21546/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21546/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21546/events","html_url":"https://github.com/Microsoft/TypeScript/issues/21546","id":293668776,"number":21546,"title":"Any number matches a numeric enum","user":{"login":"apexskier","id":329222,"avatar_url":"https://avatars3.githubusercontent.com/u/329222?v=4","gravatar_id":"","url":"https://api.github.com/users/apexskier","html_url":"https://github.com/apexskier","followers_url":"https://api.github.com/users/apexskier/followers","following_url":"https://api.github.com/users/apexskier/following{/other_user}","gists_url":"https://api.github.com/users/apexskier/gists{/gist_id}","starred_url":"https://api.github.com/users/apexskier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apexskier/subscriptions","organizations_url":"https://api.github.com/users/apexskier/orgs","repos_url":"https://api.github.com/users/apexskier/repos","events_url":"https://api.github.com/users/apexskier/events{/privacy}","received_events_url":"https://api.github.com/users/apexskier/received_events","type":"User","site_admin":false},"labels":[{"id":371615203,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Working%20as%20Intended","name":"Working as Intended","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-01T20:15:28Z","updated_at":"2018-02-01T20:27:36Z","closed_at":null,"author_association":"NONE","body":"<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:**  2.7.1\r\n\r\n<!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** enum numeric number type \r\n\r\n**Code**\r\n\r\n```ts\r\nenum TestStringEnum {\r\n    a = \"a\",\r\n    b = \"b\",\r\n}\r\n\r\nfunction testStringEnum(test: TestStringEnum) {\r\n    return test;\r\n}\r\n\r\ntestStringEnum(9); // fails (expected)\r\ntestStringEnum(\"9\"); // fails (expected)\r\ntestStringEnum(TestStringEnum.a); // passes (expected)\r\ntestStringEnum(\"a\"); // fails (???)\r\n\r\ntype TestNumberUnion = 4 | 5;\r\n\r\nfunction testNumberUnion(test: TestNumberUnion) {\r\n    return test;\r\n}\r\n\r\ntestNumberUnion(9); // fails (expected)\r\ntestNumberUnion(\"9\"); // fails (expected)\r\ntestNumberUnion(4); // passes (expected)\r\n\r\nenum TestNumberEnum {\r\n    a = 1,\r\n    b = 2,\r\n}\r\n\r\nfunction testNumberEnum(test: TestNumberEnum) {\r\n    return test;\r\n}\r\n\r\ntestNumberEnum(9); // passes (not expected)\r\ntestNumberEnum(\"9\"); // fails (expected)\r\ntestNumberEnum(TestNumberEnum.a); // passes (expected)\r\ntestNumberEnum(1); // passes (???)\r\n\r\n```\r\n\r\n**Expected behavior:**\r\nThe behavior of a string backed enum should match a number backed enum.\r\n\r\n**Actual behavior:**\r\nA number backed enum is treated as equivalent to any number.\r\n\r\n**Playground Link:** [playground link](https://www.typescriptlang.org/play/#src=enum%20TestStringEnum%20%7B%0D%0A%20%20%20%20a%20%3D%20%22a%22%2C%0D%0A%20%20%20%20b%20%3D%20%22b%22%2C%0D%0A%7D%0D%0A%0D%0Afunction%20testStringEnum(test%3A%20TestStringEnum)%20%7B%0D%0A%20%20%20%20return%20test%3B%0D%0A%7D%0D%0A%0D%0AtestStringEnum(9)%3B%20%2F%2F%20fails%20(expected)%0D%0AtestStringEnum(%229%22)%3B%20%2F%2F%20fails%20(expected)%0D%0AtestStringEnum(TestStringEnum.a)%3B%20%2F%2F%20passes%20(expected)%0D%0AtestStringEnum(%22a%22)%3B%20%2F%2F%20fails%20(%3F%3F%3F)%0D%0A%0D%0Atype%20TestNumberUnion%20%3D%204%20%7C%205%3B%0D%0A%0D%0Afunction%20testNumberUnion(test%3A%20TestNumberUnion)%20%7B%0D%0A%20%20%20%20return%20test%3B%0D%0A%7D%0D%0A%0D%0AtestNumberUnion(9)%3B%20%2F%2F%20fails%20(expected)%0D%0AtestNumberUnion(%229%22)%3B%20%2F%2F%20fails%20(expected)%0D%0AtestNumberUnion(4)%3B%20%2F%2F%20passes%20(expected)%0D%0A%0D%0Aenum%20TestNumberEnum%20%7B%0D%0A%20%20%20%20a%20%3D%201%2C%0D%0A%20%20%20%20b%20%3D%202%2C%0D%0A%7D%0D%0A%0D%0Afunction%20testNumberEnum(test%3A%20TestNumberEnum)%20%7B%0D%0A%20%20%20%20return%20test%3B%0D%0A%7D%0D%0A%0D%0AtestNumberEnum(9)%3B%20%2F%2F%20passes%20(not%20expected)%0D%0AtestNumberEnum(%229%22)%3B%20%2F%2F%20fails%20(expected)%0D%0AtestNumberEnum(TestNumberEnum.a)%3B%20%2F%2F%20passes%20(expected)%0D%0AtestNumberEnum(1)%3B%20%2F%2F%20passes%20(%3F%3F%3F))\r\n\r\n**Related Issues:**\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/362391585","html_url":"https://github.com/Microsoft/TypeScript/issues/21546#issuecomment-362391585","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21546","id":362391585,"user":{"login":"mhegazy","id":8000722,"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},"created_at":"2018-02-01T20:27:36Z","updated_at":"2018-02-01T20:27:36Z","author_association":"CONTRIBUTOR","body":"Please see https://github.com/Microsoft/TypeScript/issues/18409 for more details."}}
{"actor":{"display_login":"mhegazy"}}