Envoy_
Envoy_4w ago

ts-api-spec does not type return types when using zQuery and zMutation

I am using zod wrappers for query and mutation, even after specifying the output as zod schema, the ts-api-spec types them as any
6 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
ian
ian3w ago
thanks for catching that - I wasn't passing through the output validator to the convex returns validator. I was worried about missing fields causing the convex validator to choke, but I can make that change. would you be willing to test on an alpha? ah I remember now - we currently can generate the validator for the input of a zod validator, not the output. Do you have any .transform or .pipeline operators that would change the data type? @Envoy_ try out convex-helpers@0.1.72-alpha.1
Envoy_
Envoy_OP3w ago
I tried with this alpha release still no types for output validators. Not required as urgent, I am in a monorepo setup so types work fine by directly importing the generated api
ian
ian3w ago
If you use the alpha release, note you'll have to change your validators from output to returns - I made it a new key so it would be less likely to break any existing apps, and so it matches the convex naming.
Envoy_
Envoy_OP3w ago
Yes I changed from output to returns and now it works.
ian
ian3w ago
Once the code review goes through I'll publish it as version 0.1.73, should be in the next couple days

Did you find this page helpful?