-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptWaiting for TC39Unactionable until TC39 reaches some conclusionUnactionable until TC39 reaches some conclusion
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: "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:
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:
// extend enum using spread
enum AdvEvents {
...BasicEvents,
Pause = "Pause"<
6BAE
span class="pl-kos">,
Resume = "Resume"
};
breautek, samherrmann, ibezkrovnyi, Sladav, westy92 and 633 moretrusktr, RaduW, Sutikshan, paibamboo, alf5 and 124 morewottpal, romanrostislavovich, sevenryze, jonvuri, sh-pq and 65 moreMajidJafari, eyedean, jackhamby, HerbCaudill, moi-j and 23 more
Metadata
Metadata
Assignees
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptWaiting for TC39Unactionable until TC39 reaches some conclusionUnactionable until TC39 reaches some conclusion