Wednesday, August 21, 2013

TypeScript v0.9 enum bug

/*
Update, after upgrading to v.0.9.1 it works as it should!
*/

I think I found a bug in the TypeScript enum. in the below example the WindeDirections.None should automatically be assigned the value 4, but it's actually 0.

TypeScript code
enum WindeDirections {
    North = 0,
    South = 1,
    West = 2,
    East = 3,
    None      
}

compiled code:
var WindeDirections;
(function (WindeDirections) {
    WindeDirections[WindeDirections["North"] = 0] = "North";
    WindeDirections[WindeDirections["South"] = 1] = "South";
    WindeDirections[WindeDirections["West"] = 2] = "West";
    WindeDirections[WindeDirections["East"] = 3] = "East";

    WindeDirections[WindeDirections["None"] = 0] = "None";
})(WindeDirections || (WindeDirections = {}));

I will write about TypeScript enum in details later :-)



1 comment: