typescript-vs-flowtype icon indicating copy to clipboard operation
typescript-vs-flowtype copied to clipboard

Typescript Enums

Open itayronen opened this issue 6 years ago • 3 comments

Added a typescript unique feature: Enums

Closes https://github.com/niieani/typescript-vs-flowtype/issues/57

itayronen avatar Aug 20 '19 15:08 itayronen

@niieani I'm not sure, "const enums" should be mentions, because time after time the TS team against using it in every issue arise about them

oriSomething avatar Aug 23 '19 06:08 oriSomething

There is missing about enums:

  • Enums are the only nominal types in TS
  • About number enums: They are always mixed with strings (unlike only string enums)
enum E { a, b } = { a: 0, b: 1, 0: "a", 1: "b" };

oriSomething avatar Aug 23 '19 06:08 oriSomething

Agree const enum are not something worth covering. Its a bundle size optimization. Number enums are not always mixes with string values, you can get the enum key by its value (and vice versa).

I'll add the info about the additional emitted code. With that said, typescript emits more code than just enums, depends on the ES version you target. It might (Im not sure) be the only additional code if you target es7+.

itayronen avatar Aug 24 '19 16:08 itayronen