Title: Allow enums in local scopes · Issue #3217 · microsoft/TypeScript · GitHub
Open Graph Title: Allow enums in local scopes · Issue #3217 · microsoft/TypeScript
X Title: Allow enums in local scopes · Issue #3217 · microsoft/TypeScript
Description: Currently the following is allowed: enum Color { red, green, blue } function fun(myColor) { if (myColor == Color.red) { console.log("awesome"); } else { console.log("bummer"); } } This compiles, but gives a warning: function fun(myColor)...
Open Graph Description: Currently the following is allowed: enum Color { red, green, blue } function fun(myColor) { if (myColor == Color.red) { console.log("awesome"); } else { console.log("bummer"); } } This compiles, bu...
X Description: Currently the following is allowed: enum Color { red, green, blue } function fun(myColor) { if (myColor == Color.red) { console.log("awesome"); } else { console.log("bummer"); }...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3217
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow enums in local scopes","articleBody":"Currently the following is allowed:\n\n``` typescript\nenum Color { red, green, blue }\n\nfunction fun(myColor) {\n if (myColor == Color.red) {\n console.log(\"awesome\");\n } else {\n console.log(\"bummer\");\n }\n}\n```\n\nThis compiles, but gives a warning:\n\n``` typescript\nfunction fun(myColor) {\n enum Color { red, green, blue } // Warning \"Statement expected\"\n\n if (myColor == Color.red) {\n console.log(\"awesome\");\n } else {\n console.log(\"bummer\");\n }\n}\n```\n\nEspecially when refactoring existing JavaScript code, there are cases where an enum would be useful, but wouldn't be used outside of a single function. In those cases, I think it makes sense to allow the enum to be defined inside of the function's scope.\n","author":{"url":"https://github.com/joshuacc","@type":"Person","name":"joshuacc"},"datePublished":"2015-05-19T15:59:54Z","url":"https://github.com/microsoft/TypeScript/issues/3217"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f5ee6f13-bfbf-e537-b001-1001bb134e9a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B300:20AA01:85581A:ACD94B:6B00D9BB |
| html-safe-nonce | 4c93b21bcf3a0ad4f5f4dd34abc1466c9c429357d2f1c9cf7441a8c0de4d3b7a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzAwOjIwQUEwMTo4NTU4MUE6QUNEOTRCOjZCMDBEOUJCIiwidmlzaXRvcl9pZCI6IjUwNTUwNTUzNjk2MzQ2MzQxNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c97c330bc631f177b6041ff9dbe092538f4836156a26114266b495745054b014 |
| hovercard-subject-tag | issue:78147243 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/3217/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ea14da28d68b3665b47e313d5209359701453ee096994049fce81ef62b00aa2/microsoft/TypeScript/issues/3217 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ea14da28d68b3665b47e313d5209359701453ee096994049fce81ef62b00aa2/microsoft/TypeScript/issues/3217 |
| og:image:alt | Currently the following is allowed: enum Color { red, green, blue } function fun(myColor) { if (myColor == Color.red) { console.log("awesome"); } else { console.log("bummer"); } } This compiles, bu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joshuacc |
| hostname | github.com |
| expected-hostname | github.com |
| None | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width