Closed
Description
Consider the following enum.
enum A {
Name,
LongName,
ReallyLongName
}
It's javascript output is
var A;
(function (A) {
A[A["Name"] = 0] = "Name";
A[A["LongName"] = 1] = "LongName";
A[A["ReallyLongName"] = 2] = "ReallyLongName";
})(A || (A = {}));
but would be much more succinct if it were output as
var A;
(function (A) {
A[A[0] = "Name"] = 0;
A[A[1] = "LongName"] = 1;
A[A[2] = "ReallyLongName"] = 2;
})(A || (A = {}));
The only benefit to this change would be minification of the output javascript. Running the two versions in a minifier I'm getting the current output minified at 116 bytes and the proposed way at 96 bytes for a difference of about 17%. Obviously, this difference would be influenced by the number of enum members and the length of the enum members' names.
This change would only be applicable to enum members with a constant value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment