Skip to content

Commit

Permalink
fix(rest): remove const enums in favour of regular enums (#9243)
Browse files Browse the repository at this point in the history
* fix(rest): remove `const enum`s in favour of regular enums

The motivation is that `const enum` produces ambient const enums when
compiling which in turn causes issues with TypeScript 5.x when `verbatimModuleSyntax`
is enabled.

Furthermore, the generally accepted best practice is to avoid `const enum`s
when writing libraries. Can back this up with statements from TS maintainers
if needed, I know they made them, I just can't be bothered to find the GitHub
links lmao. @vladfrangu will probably be able to find those links much easier
than me as it was also the motivation to remove `const enum`'s from discord-api-types

* refactor(rest): restore `const enum` for internal enum

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
favna and kodiakhq[bot] committed Mar 19, 2023
1 parent 2e8e950 commit 229ad07
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rest/src/lib/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export interface RequestHeaders {
/**
* Possible API methods to be used when doing requests
*/
export const enum RequestMethod {
export enum RequestMethod {
Delete = 'DELETE',
Get = 'GET',
Patch = 'PATCH',
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DefaultRestOptions = {
/**
* The events that the REST manager emits
*/
export const enum RESTEvents {
export enum RESTEvents {
Debug = 'restDebug',
HandlerSweep = 'handlerSweep',
HashSweep = 'hashSweep',
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"preserveConstEnums": true,
"removeComments": false,
"sourceMap": true,
"esModuleInterop": true,
Expand Down

2 comments on commit 229ad07

@vercel
Copy link

@vercel vercel bot commented on 229ad07 Mar 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 229ad07 Mar 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.