Enums are fine, just don't forget to use Object.freeze(enumName) afterwards!!
Apart from that, because Typescript has powerful union types, not using enum is perfectly fine as well, for example instead of:
enum Relation { Less = -1, Equal, Greater }
Object.freeze(Relation);
you could do instead:
const Less = -1;
type Less = -1;
const Equal = 0;
type Equal = 0;
const Greater = 1;
type Greater = 1;
type Relation = Less | Equal | Greater;
Apparently you need the additional "type Less" etc. declarations, I would have thought it should work without.
As for private and #, the biggest disadvantage of # is that it is so slow currently. But that will change hopefully soon when # is not compiled as WeakMaps by TypeScript. I would hope they compile private to # later on, backwards compatibility be damned :-D
It's true the down-levelled code that uses WeakMaps is slower. The decision to downlevel is in the hands of the user and is controlled by the tsconfig "target" option.
The only environment that needs downlevelled #private fields is IE11.
Which value are you setting for target? I tried es2021, and it still doesn't give me native #. I cannot use esnext, because other stuff doesn't compile anymore.
Apart from that, because Typescript has powerful union types, not using enum is perfectly fine as well, for example instead of:
you could do instead: Apparently you need the additional "type Less" etc. declarations, I would have thought it should work without.As for private and #, the biggest disadvantage of # is that it is so slow currently. But that will change hopefully soon when # is not compiled as WeakMaps by TypeScript. I would hope they compile private to # later on, backwards compatibility be damned :-D