Hacker News new | ask | show | jobs
by glitchdout 2822 days ago
It's not that simple because you can reverse lookup a TS enum. So:

    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.

1 comments

Ah that's a good point, thanks for bringing it. I did know TS enums supported that, I thought it was just some syntax sugar for a hashmap.