Opinion on DX of this code, is it too confusing or easy to grasp?
Just wanted to get some second opinions on a fun library I'm working on. I'm reaching a point where typescript limitations are making me have to do strange patterns to get my desired behavior, so I want to try to pick a variation of it that resonates with other people and not just myself.
As of the moment these are the only 2 that I could imagine, but if anyone has an idea on another way that I could return a type value/object and export them so that they appear as the same type.
Additionally, is it safe to say that the top version is the more 'normal' version and the bottom one is definitely more react-like because of the array destrucuring or is that something common in all of javascript?
2 Replies
i’m not sure where
makeEnum()
comes from, so it might be better, but I’ve been using zod’s enum like const roles = z.enum([“User”, “Admin”, “Owner”])
its a library I've been working on that I put on npm earlier today. I wasn't aware zod even had enums but they look interesting, though a bit more verbose than I would prefer. My library the set up is slightly more verbose but the trade off is more concise usage
eg.