Title: Extending string-based enums · Issue #17592 · microsoft/TypeScript · GitHub
Open Graph Title: Extending string-based enums · Issue #17592 · microsoft/TypeScript
X Title: Extending string-based enums · Issue #17592 · microsoft/TypeScript
Description: Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: const BasicEvents = { Start: "Start", Finish: "Finish" }; const AdvEvents = { ...BasicEvents, Pause: "Pause", Resume: ...
Open Graph Description: Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: const BasicEvents = { Start: "Start", Finish: "Finish" }; const AdvEvents = { ...
X Description: Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: const BasicEvents = { Start: "Start", Finish: "Finish" }; ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17592
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extending string-based enums","articleBody":"Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example:\r\n```ts\r\nconst BasicEvents = {\r\n Start: \"Start\",\r\n Finish: \"Finish\"\r\n};\r\n\r\nconst AdvEvents = {\r\n ...BasicEvents,\r\n Pause: \"Pause\",\r\n Resume: \"Resume\"\r\n};\r\n```\r\n\r\nWhen switching over to string enums, it\"s impossible to achieve this without re-defining the enum.\r\n\r\nI would be very useful to be able to do something like this:\r\n\r\n```ts\r\nenum BasicEvents {\r\n Start = \"Start\",\r\n Finish = \"Finish\"\r\n};\r\n\r\n// extend enum using \"extends\" keyword\r\nenum AdvEvents extends BasicEvents {\r\n Pause = \"Pause\",\r\n Resume = \"Resume\"\r\n};\r\n```\r\n\r\nConsidering that the produced enums are objects, this won\"t be too horrible either:\r\n```ts\r\n// extend enum using spread\r\nenum AdvEvents {\r\n ...BasicEvents,\r\n Pause = \"Pause\",\r\n Resume = \"Resume\"\r\n};\r\n```\r\n","author":{"url":"https://github.com/nomaed","@type":"Person","name":"nomaed"},"datePublished":"2017-08-03T16:51:38Z","url":"https://github.com/microsoft/TypeScript/issues/17592"}
| 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:c8b17904-eaaf-1857-cb46-96ee7ba8f4d6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB10:102D75:3D39D:4DF88:6B00F19B |
| html-safe-nonce | a8b1b4f397b4a67765cf50ec08c4087c19b8dd626a9aef57469b5005360b6dd2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjEwOjEwMkQ3NTozRDM5RDo0REY4ODo2QjAwRjE5QiIsInZpc2l0b3JfaWQiOiIxMzgwMzA2NzU1OTA4NTk2MTIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6b56b6a42d18a9176beb22f29ef1b974184c802e4c854a086a52027b16f232e7 |
| hovercard-subject-tag | issue:247770146 |
| 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/17592/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c32aae99dfb8070bc2458c16158b2539f482d268afae6568f5c35659bce10e7d/microsoft/TypeScript/issues/17592 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c32aae99dfb8070bc2458c16158b2539f482d268afae6568f5c35659bce10e7d/microsoft/TypeScript/issues/17592 |
| og:image:alt | Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: const BasicEvents = { Start: "Start", Finish: "Finish" }; const AdvEvents = { ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nomaed |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width