Extending string-based enums
Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: ```ts const BasicEvents = { Start: "Start", Finish: "Finish" }; const AdvEvents = { ...BasicEvents, Pause: "Pause", Resume: "Resume" }; ``` When switching over to string enums, it"s impossible to achieve this without re-defining the enum. I would be very useful to be able to do something like this: ```ts enum BasicEvents { Start = "Start", Finish = "Finish" }; // extend enum using "extends" keyword enum AdvEvents extends BasicEvents { Pause = "Pause", Resume = "Resume" }; ``` Considering that the produced enums are objects, this won"t be too horrible either: ```ts // extend enum using spread enum AdvEvents { ...BasicEvents, Pause = "Pause", Resume = "Resume" }; ```
Posted by nomaed on Aug 3, 2017, 4:51 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Extending string-based enums
Before string based enums, many would fall back to objects. Using objects also allows extending of types. For example: ```ts const BasicEvents = { Start: "Start", Finish: "Finish" }; const AdvEvents = { ...BasicEvents, Pause: "Pause", Resume: "Resume" }; ``` When switching over to string enums, it"s impossible to achieve this without re-defining the enum. I would be very useful to be able to do something like this: ```ts enum BasicEvents { Start = "Start", Finish = "Finish" }; // extend enum using "extends" keyword enum AdvEvents extends BasicEvents { Pause = "Pause", Resume = "Resume" }; ``` Considering that the produced enums are objects, this won"t be too horrible either: ```ts // extend enum using spread enum AdvEvents { ...BasicEvents, Pause = "Pause", Resume = "Resume" }; ```
Comments (0)
No comments yet. Start the discussion.