-
Notifications
You must be signed in to change notification settings - Fork 106
Generated "const enum OrderDirection" clashes with isolatedModules #316
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
Comments
I can add some zeus config in the future. Exporting enums is considered bad practice, const enums are much lighter but get hidden during transpilation |
A lot of people asked for const enums before instead of enums |
How about avoiding enums entirely and just making it a union of strings? |
ok I'll try and test that with different projects and if it won't cause problems I will change it |
For the reasons explained by @iainmerrick and @aexol we were actually not able to use either To avoid this, we patched this part and indeed used string unions. In the following screenshot, you can see our output on the left and the original Zeus output on the right: We've been using this on our codebase for a few months and are happy with it. If this is something that looks good, I'm ready to do a PR to add this option using a flag. 🙂 It it can be useful for someone else, here's the commit on our fork to apply this change: elba-security/graphql-zeus@ |
Hello @aexol Any news regarding this issue ? It would be nice to have an option during generation to satisfy everyone Thank you. |
This week I will upload new zeus with config and option to generate different enums. Sorry for delay |
Is this option available in 5.4.2? Any CLI example? Faced this issue with NextJS and separate zeus client library. NextJS forces usage of UPD:
|
Also running into this when trying to use the enums generated by Zeus in my NestJS API. The const enums that are generated can't be used as an enum type on Nest objects so I'm having to re-define the enum and map between the two. Would be great to see this compile option added. |
enums done - now standard are normal enums and if you want constEnums you need a flag |
I'm using Zeus to generate bindings in one NPM package, and attempting to import and use them in another package.
I'm hitting type errors around this generated code:
The problem is that many clients configure TS with
isolatedModules: true
, which leads to a type error on import:Using
"asc"
and"desc"
directly in the client code doesn't work either, for reasons I can't quite fathom:I don't fully understand why TypeScript can't be configured to handle this, but it seems like exporting const enums is generally considered bad practice:
Can this be fixed by changing the exported declaration? I think this might work:
The text was updated successfully, but these errors were encountered: