-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Generate const array of possible enum values #832
Comments
Sorry for the late reply on this. I believe we are currently generating typescript enums. Is it not sufficient to zod schema? |
No, you are generating unions of string literals, which is a different thing. The current types that are generated can only be used for static type-checking (unlike proper Typescript enums.) |
@sweatybridge , could you please reopen this feature request As @toBeOfUse notes, the code does not generate typescript enums (which are values), it generates string literal unions (which are types). ( The types generated currently are removed by the typescript compiler and cannot be used at runtime. Generated values are useful both for the zod case and for iterating over values. |
A workaround is present in #864 |
Reopened this gauge interest on generating values in addition to types. |
This is a kind of a duplicate of #864 now |
#901 looks good to me |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I would like to have values matching possible enum values that are synchronized to the database schema for looping or use with zod and similar tools.
Describe the solution you'd like
A clear and concise description of what you want to happen.
for a schema:
I would like to have generated values:
this would allow defining zod types to match like:
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: