-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms
For now TypeScript will transform enum from
enum Test {
Key = 1
}to
var Test;
(function (Test) {
Test[Test["Key"] = 1] = "Key";
})(Test || (Test = {}));This result is not friendly for uglyify or tree-shaking.
When Test is not be used, the generated code block always remain as dead codes.
Suggestion
prefer to generate codes below:
var Test = /*#__PURE__*/(function () {
var e = {}
e[e["Key"] = 1] = "Key";
return e
})();Examples
The suggestion version will be removed.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
NewFuture, elado, ajihyf, slavafomin, cblanc and 25 more
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
