Furthering a discussion between myself and @gentlementlegen during code review regarding the usage of const enums vs Enums and which of the two should it be?
I'm against the usage of Enums as they are not an extension of JS which TS should be. They introduce more JS than compared to a const enum and are not considered a best practice in TS as far as I understand things.
Objects vs Enums
In modern TypeScript, you may not need an enum when an object with as const could suffice: ...
The biggest argument in favour of this format over TypeScript’s enum is that it keeps your codebase aligned with the state of JavaScript, and when/if enums are added to JavaScript then you can move to the additional syntax.
I'm not saying replace all Enums across the org but when/if possible we should use const enums.
Furthering a discussion between myself and @gentlementlegen during code review regarding the usage of
const enums
vsEnums
and which of the two should it be?I'm against the usage of
Enums
as they are not an extension of JS which TS should be. They introduce more JS than compared to aconst enum
and are not considered a best practice in TS as far as I understand things.https://www.typescriptlang.org/docs/handbook/enums.html#const-enums
I'm not saying replace all
Enums
across the org but when/if possible we should useconst enums
.Penny for your thoughts?
_original context https://github.com/ubiquibot/command-start-stop/pull/1#discussion_r1634255389_