Replies: 1 comment
-
In 6.24.0 you can generate native Typescript enums now with an option. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, when orval parses enums, it generates an object and a type (which is derived from the object). For example:
I think there are a few benefits of generating an array, rather than an object:
Zod enums
Using the array syntax works very well with zod enums:
But not with the object syntax:
Better inference when iterating
In the array syntax:
In the object syntax:
Type guard
Using the array syntax can be used as a type guard:
Which does not work with the object syntax:
Note that this currectly only works when updating the
includes
signature like this.Conclusion
These are just some of the use cases I found for using the array syntax while working on a large typescript project that is using orval heavily. On the other hand, I did not find any use (yet) to the object syntax.
What is your opinion on adding an option to orval config to choose how the enums will be generated?
Beta Was this translation helpful? Give feedback.
All reactions