Karol
Karol6mo ago

Using output validator breaks query return type inference on react query

Hi! I am not sure whether this is expected and whether there is some way to fix that but here it goes. I am using trpc (up to date 11 beta) on nextjs set up according to trpc website guide and use react-query integration as presented on screens. When I skip .output([some validator here]) on procedure definition, return types are correctly inferred and data is as presented on screen. However when I add output validation (see other screen), the returned data type is set to unknown. Am I missing something somewhere? I want to use output validator and still have benefit of using types on my frontend. I have not found any issue or mention of similar issue anywhere so maybe I am doing something wrong there. Appreciate the help!
No description
No description
Solution:
Ok I resolved my issue myself, it's that I did not have strict null checks turned on on my component directory since I haven't managed to turn it on everywhere yet. When I turn it on, types are inferred correct. Case closed.
Jump to solution
1 Reply
Solution
Karol
Karol6mo ago
Ok I resolved my issue myself, it's that I did not have strict null checks turned on on my component directory since I haven't managed to turn it on everywhere yet. When I turn it on, types are inferred correct. Case closed.