TypeScript enumerations when compiled in simple JS contain both a symbolic name and numeric values ββas properties, and this explains why you get FrontEnd, BackEnd, Designer, 0, 1, 2 when trying to enumerate object properties. As far as I know, there is no compilation method to list only symbolic names. You can list all of them and skip all that is a number.
From this article, you can see exactly how the TypeScript enumerator compiles in JS.
If you have this TypeScript:
It compiles into this Javscript:
//Compiled javascript: var StandardEnum; (function (StandardEnum) { StandardEnum[StandardEnum["FirstItem"] = 0] = "FirstItem"; StandardEnum[StandardEnum["SecondItem"] = 1] = "SecondItem"; StandardEnum[StandardEnum["ThirdItem"] = 2] = "ThirdItem"; })(StandardEnum || (StandardEnum = {})); ;
This is essentially this result:
var StandardEnum = { "FirstItem": 0, "SecondItem": 1, "ThirdItem": 2, "0": "FirstItem", "1": "SecondItem", "2": "ThirdItem" };
So, unless you specifically ignore numeric properties, there is no way to list only enumeration names.
You can do it like this:
for (var item in StandardEnum) { if (StandardEnum.hasOwnProperty(item) && !/^\d+$/.test(item)) { console.log(item); } }
Working demo: http://jsfiddle.net/jfriend00/65cfg88u/
FYI if you really want:
var StandardEnum = { "FirstItem": 0, "SecondItem": 1, "ThirdItem": 2 };
Then maybe you shouldn't use an enumeration and just use this standard JS declaration. Then you can get the properties using Object.keys(StandardEnum) .