Title: String Enum Initializer · Issue #16464 · microsoft/TypeScript · GitHub
Open Graph Title: String Enum Initializer · Issue #16464 · microsoft/TypeScript
X Title: String Enum Initializer · Issue #16464 · microsoft/TypeScript
Description: String Enum Initializer A more typesafe and succinct way of defining enum types that compile to strings Search Terms enum, string, string enum default value initializer infer Proposal It seems like you should be able to specify that you ...
Open Graph Description: String Enum Initializer A more typesafe and succinct way of defining enum types that compile to strings Search Terms enum, string, string enum default value initializer infer Proposal It seems like...
X Description: String Enum Initializer A more typesafe and succinct way of defining enum types that compile to strings Search Terms enum, string, string enum default value initializer infer Proposal It seems like...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/16464
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String Enum Initializer","articleBody":"# String Enum Initializer\r\nA more typesafe and succinct way of defining enum types that compile to strings\r\n\r\n## Search Terms\r\nenum, string, string enum\r\ndefault value\r\ninitializer\r\ninfer\r\n\r\n## Proposal\r\nIt seems like you should be able to specify that you are using a string enum, and then you'd only have to write out the 'value' once, and it would be automatically made into a string matching the enum code.\r\n\r\n```typescript\r\nenum\u003cstring> Action {\r\n LOAD_PROFILE,\r\n ADD_TASK,\r\n REMOVE_TASK\r\n}\r\n```\r\n\r\nor \r\n\r\n```typescript\r\nenum Action: string {\r\n LOAD_PROFILE,\r\n ADD_TASK,\r\n REMOVE_TASK\r\n}\r\n```\r\n\r\ninstead of \r\n\r\n```typescript\r\nenum Action {\r\n LOAD_PROFILE = \"LOAD_PROFILE\",\r\n ADD_TASK = \"ADD_TASK\",\r\n REMOVE_TASK = \"REMOVE_TASK\"\r\n}\r\n```\r\nThanks for all the great work!\r\n\r\n**EDIT**\r\nRecently updated to reflect variations proposed by @imcotton [here](https://github.com/microsoft/TypeScript/issues/16464#issuecomment-317595199) and @lostpebble [here](https://github.com/microsoft/TypeScript/issues/16464#issuecomment-325325553); as well as search terms proposed by @KennethKo (#36319) and @garrettmaring (#33015)","author":{"url":"https://github.com/thomasmost","@type":"Person","name":"thomasmost"},"datePublished":"2017-06-12T21:18:11Z","url":"https://github.com/microsoft/TypeScript/issues/16464"}
| 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:1eaf210f-8734-f334-0bfb-70e9bf5fc13d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B4D2:19114D:9645FA:C36349:6B00DE3E |
| html-safe-nonce | ea80bc5a1533f831eff02d16cf1a97160ba6733f7ab86acdd2996d0e42de9ee9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNEQyOjE5MTE0RDo5NjQ1RkE6QzM2MzQ5OjZCMDBERTNFIiwidmlzaXRvcl9pZCI6IjEyNTQwOTY5NDI4OTIzNzU2MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c4b12d5d09cfc3646b291bcffb213d234ea590e00bba309ef7011d073959ce47 |
| hovercard-subject-tag | issue:235368663 |
| 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/16464/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9b1941372df140ee3466168e09df544b58b0dc4d5e45c0a3e715e8c1d3c7cb5/microsoft/TypeScript/issues/16464 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9b1941372df140ee3466168e09df544b58b0dc4d5e45c0a3e715e8c1d3c7cb5/microsoft/TypeScript/issues/16464 |
| og:image:alt | String Enum Initializer A more typesafe and succinct way of defining enum types that compile to strings Search Terms enum, string, string enum default value initializer infer Proposal It seems like... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thomasmost |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width