Unlike CoffeeScript, you can't have any technical debt with TypeScript, if one day TypeScript disapears, you just remove the types and you have a perfectly working JS file.
enum Color { red = 1, green = 2, blue = 4 }
namespace Color { export function mixColor(colorName: string) { if (colorName == "yellow") { return Color.red + Color.green; } else if (colorName == "white") { return Color.red + Color.green + Color.blue; } else if (colorName == "magenta") { return Color.red + Color.blue; } else if (colorName == "cyan") { return Color.green + Color.blue; } } }
* Edited with a better example.
enum Color { Red = 1, Green = 2 }
would be the same as: var Color = {
Red: 1,
1: 'Red',
Green: 2,
2: 'Green'
}
See for yourself:
https://www.typescriptlang.org/play/#src=enum%20Color%7B%0D%...But I agree with you, it would be quite easy for an automated tool to replace a TS enum with pure JS.