Closed Aqours closed 7 years ago
You could try changing the TS code to
if (PlayOrderEnum["Reverse"]) { console.log('good'); }
@shivensinha4 You are right. But without advantage of code insight
It's not TypeScript's job to guess around at what your minifier might be doing.
@RyanCavanaugh I think that the fake key in enum is string type, so compiled code should be string type, which is not relative to minifier. enum is not object, so PlayOrderEnum['Reverse']
is better than PlayOrderEnum.Reverse
.
@Aqours Sure, if that happens to be your opinion. But a compiler must give the programmer the maximum amount of control of the output. Say, if you wanted the transpiled code to have foo.bar in it, maybe due to the the specific style of code of your project, and if the compiler always converts it into foo['bar'], wouldn't it be frustrating? The current behaviour of the compiler allows both the options.
TypeScript Version: 2.4.2
Code
Expected behavior:
Actual behavior: