From 229ad077ff52d8706d68ed4d31983619a32eba45 Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Sun, 19 Mar 2023 15:35:27 +0100 Subject: [PATCH] fix(rest): remove `const enum`s in favour of regular enums (#9243) * 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> --- packages/rest/src/lib/RequestManager.ts | 2 +- packages/rest/src/lib/utils/constants.ts | 2 +- tsconfig.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/rest/src/lib/RequestManager.ts b/packages/rest/src/lib/RequestManager.ts index 364072130..480aa33bb 100644 --- a/packages/rest/src/lib/RequestManager.ts +++ b/packages/rest/src/lib/RequestManager.ts @@ -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', diff --git a/packages/rest/src/lib/utils/constants.ts b/packages/rest/src/lib/utils/constants.ts index 03381c70e..aada602fb 100644 --- a/packages/rest/src/lib/utils/constants.ts +++ b/packages/rest/src/lib/utils/constants.ts @@ -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', diff --git a/tsconfig.json b/tsconfig.json index 353b71229..90895f984 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,7 +28,6 @@ "newLine": "lf", "noEmitHelpers": true, "outDir": "dist", - "preserveConstEnums": true, "removeComments": false, "sourceMap": true, "esModuleInterop": true,