Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from const enums #295

Closed
ghostdevv opened this issue Jan 10, 2022 · 4 comments · Fixed by #306
Closed

Move from const enums #295

ghostdevv opened this issue Jan 10, 2022 · 4 comments · Fixed by #306

Comments

@ghostdevv
Copy link

Is your feature request related to a problem? Please describe.
I need to access one of the enums (ApplicationCommandOptionType) but do it dynamically, currently it's a const enum so you are unable to do that

Describe the ideal solution
It's made a non const enum

Describe alternatives you've considered
Copying and pasting the enum into my project (I will then have to make sure I constantly update this which works but isn't ideal)

Additional context
Would be worth doing this on discord.js itself if there aren't plans to fully use this package on djs

@vladfrangu
Copy link
Member

vladfrangu commented Jan 10, 2022

What's the use case for this? Getting the PascalCase names? The reason these enums are const and will most likely stay that way is to inline their values in the compiled code when using TS 👀

@ghostdevv
Copy link
Author

I need to convert a string type such as INTEGER to it's type number so I can send that off to the discord api @vladfrangu
the commands are dynamically imported and processed at runtime so it can't be done at compile time

I wonder how discord.js does it for non typescript users providing INTEGER (how it resolves that to it's type number to send to the api

@sylv
Copy link

sylv commented Jan 24, 2022

I've also had this issue. NextJS uses the isolatedModules compiler option which doesn't allow const enums, causing our dashboard to have magical numbers thrown around when doing things like filtering and displaying channels, each one requiring comments explaining what its representing. It also prevents dynamic lists using ts-enum-util for something like an option type dropdown, or using enums for validation with @IsEnum from class-validator

For now I've just stuck with copy/pasting enums without const for validation and some dynamic lists or not using them at all for filtering and other static use cases with isolatedModules enabled, but it would be really nice if it just wasn't an issue to begin with.

@ghostdevv
Copy link
Author

Would be great to do this for sure especially now that discordjs/discord.js#7270 is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants