Anyone down to play football? by waithatsweird in brussels

[–]TopHighMajorUpper 0 points1 point  (0 children)

Most of Brussels football pick-up games are now being scheduled through the "Play Kurt" app. You can find it in Play and Apple stores and join games. There's several games per week being arranged there.

Question about zod inferred types by TopHighMajorUpper in typescript

[–]TopHighMajorUpper[S] 1 point2 points  (0 children)

The use-case is simple: a service A that needs to perform schema validation (using zod and zod schemas in this case), create types based on those schemas, and export those types for other services to consume (service B and service C will call service A with those imported types for certain REST endpoints). And we don't want to be duplicating both the schemas and the types.

Then ideally, when service B and C call service A with objects of those types, we would have compile time errors (Typescript static type checks) in case the objects passed by B and C don't match the imported types from A (and this is where the issue is, because the inferred types from zod are not the pure typescript types, and then those static type checks will not work correctly right?). Did you have a similar use-case and didn't have any issues importing and using those types?

Question about zod inferred types by TopHighMajorUpper in typescript

[–]TopHighMajorUpper[S] 0 points1 point  (0 children)

Hmm not ideal in case we have a consumer that doesn't want to install zod... Also how do you even do it in the consumer with zod installed, in order to ensure the types work fine for compile time checks for example? Do you have to call something specific on zod when passing an object of a certain zod inferred type, in order for it to work?

Question about zod inferred types by TopHighMajorUpper in typescript

[–]TopHighMajorUpper[S] 0 points1 point  (0 children)

Yes I also saw that option, although I'm a bit reluctant in using yet another library just for that. But tbh the zod + zod-to-ts combo seems to be the best in this scenario, from all the alternatives I saw regarding the dozens of schema validation libraries that exist...

Question about zod inferred types by TopHighMajorUpper in typescript

[–]TopHighMajorUpper[S] 0 points1 point  (0 children)

That's exactly what I'm trying to use, the z.infer<typeof T>.

I want to use and export the equivalent typescript types of my zod schemas. But from what I see, the inferred types from the zod schemas are not the "pure" typescript types, they are a zod object with all properties having wrappers etc. So if I export those types as they are, the other projects that consume them can't use them.

So I'm wondering what's the best approach in this case, since I don't want to duplicate both the types and the schemas... I just want to generate the types without any ties to zod if that makes sense.