It seems like the typescript compiler being used is version pre-2.4, where string value support was not yet added in enums. Typically, there's a reverse mapping from values to enums and values are usually numbers. However, if you tried to use strings before version 2.4, the compiler wouldn't know how to handle it (and would actually result in errors), but it would still generate the source code.
Contrast with version 2.4:
var Sizes;
(function (Sizes) {
Sizes["Tiny"] = "Tiny";
Sizes["VerySmall"] = "Very Small";
Sizes["Small"] = "Small";
Sizes["Medium"] = "Medium";
Sizes["Large"] = "Large";
Sizes["VeryLarge"] = "Very Large";
})(Sizes || (Sizes = {}));
Versus version 2.3:
var Sizes;
(function (Sizes) {
Sizes[Sizes["Tiny"] = "Tiny"] = "Tiny";
Sizes[Sizes["VerySmall"] = "Very Small"] = "VerySmall";
Sizes[Sizes["Small"] = "Small"] = "Small";
Sizes[Sizes["Medium"] = "Medium"] = "Medium";
Sizes[Sizes["Large"] = "Large"] = "Large";
Sizes[Sizes["VeryLarge"] = "Very Large"] = "VeryLarge";
})(Sizes || (Sizes = {}));
And version 2.3 without string values:
var Sizes;
(function (Sizes) {
Sizes[Sizes["Tiny"] = 0] = "Tiny";
Sizes[Sizes["VerySmall"] = 1] = "VerySmall";
Sizes[Sizes["Small"] = 2] = "Small";
Sizes[Sizes["Medium"] = 3] = "Medium";
Sizes[Sizes["Large"] = 4] = "Large";
Sizes[Sizes["VeryLarge"] = 5] = "VeryLarge";
})(Sizes || (Sizes = {}));
If you wish to enforce that reverse mapping in versions 2.4 and higher, you can assert the values to any
.
enum Sizes {
Tiny = <any>"Tiny",
VerySmall = <any>"Very Small",
Small = <any>"Small",
Medium = <any>"Medium",
Large = <any>"Large",
VeryLarge = <any>"Very Large"
}
We'll just consider it a feature.