Title: string enums: Infer default value from key · Issue #36319 · microsoft/TypeScript · GitHub
Open Graph Title: string enums: Infer default value from key · Issue #36319 · microsoft/TypeScript
X Title: string enums: Infer default value from key · Issue #36319 · microsoft/TypeScript
Description: Search Terms string enum default value initializer infer Suggestion Add syntactic sugar to string enum declarations to infer their values from their key names. The overwhelming majority of string enum values are identical or near-identic...
Open Graph Description: Search Terms string enum default value initializer infer Suggestion Add syntactic sugar to string enum declarations to infer their values from their key names. The overwhelming majority of string e...
X Description: Search Terms string enum default value initializer infer Suggestion Add syntactic sugar to string enum declarations to infer their values from their key names. The overwhelming majority of string e...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/36319
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"string enums: Infer default value from key","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\nstring enum \r\ndefault value\r\ninitializer\r\ninfer\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\n\r\n## Suggestion\r\n\r\nAdd syntactic sugar to string enum declarations to infer their values from their key names. The overwhelming majority of string enum values are identical or near-identical to their key names, and it's kludgy to list every reserved value twice in its declaration.\r\n\r\n```\r\nenum\u003cstring> Foo {\r\n A,\r\n B,\r\n ...,\r\n Y = 'LegacyOverrideYValue',\r\n Z,\r\n LongAndSimilarEnumName,\r\n LongUnsimilarEnumName,\r\n}\r\n\r\n// instead of \r\n\r\nenum Foo {\r\n A = 'A',\r\n B = 'B',\r\n ...,\r\n Y = 'LegacyOverrideYValue',\r\n Z = 'Z',\r\n LongAndSimilarEnumName = 'LongAndSimilarEnumName',\r\n LongUnsimilarEnumName = 'LongUnSimilarEnumName',\r\n}\r\n// which contains a sneaky bug\r\n```\r\n\r\n","author":{"url":"https://github.com/KennethKo","@type":"Person","name":"KennethKo"},"datePublished":"2020-01-20T21:08:56Z","url":"https://github.com/microsoft/TypeScript/issues/36319"}
| 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:7e61458e-f872-4290-5317-bf1609395185 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9B0:16EED3:692A67:879601:6B00E1A7 |
| html-safe-nonce | 32ab614783eca7088c1a573daeb72cd36882e849b2aa3d803e422fc406c18f6c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUIwOjE2RUVEMzo2OTJBNjc6ODc5NjAxOjZCMDBFMUE3IiwidmlzaXRvcl9pZCI6IjQ4NTcyOTkyODcwMjcwMTYxMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7df93888e949119b26ed8cc58d8b6de93135fd09e02caf8b9339ae85d78150d5 |
| hovercard-subject-tag | issue:552509448 |
| 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/36319/issue_layout |
| twitter:image | https://opengraph.githubassets.com/37d570dcfcef6ac4caba44692ecdb33d3c3ba5fdcf0312dbb9601221a384231d/microsoft/TypeScript/issues/36319 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/37d570dcfcef6ac4caba44692ecdb33d3c3ba5fdcf0312dbb9601221a384231d/microsoft/TypeScript/issues/36319 |
| og:image:alt | Search Terms string enum default value initializer infer Suggestion Add syntactic sugar to string enum declarations to infer their values from their key names. The overwhelming majority of string e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | KennethKo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width