Is there a better way to access enum types?
is there a better way to do this other than manually creating a type to use everywhere? its not very ergonomic to type this out like that
i can also do something like
but this sucks too
4 Replies
What I do is I create the array as const, create the type from it, and then pass it to the pgEnum function
then how do you get the types in code? just MarketplaceIntegrationTypes[number]
Oh yeah, forgot that, the type should have [number] at the end
coming back to this conversation as i feel like working with enums is still annoying
as you mentioned above we can do this workaround to get the types but what if i have a function and i want to check if the
maketPlaceIntegration
is Amazon
with a typescript enum i would have something like this but this is not possible with pgEnum