Dynamic return type
Is there any way to have dynamic return type with tRPC?
Simple example:
If I provide x: true on body, let me send number, otherwise string.
But mainly, I want to use it for select fields on database
Solution:Jump to solution
Is there any way to have dynamic return type with tRPC?
Simple example:
If I provide x: true on body, let me send number, otherwise string.
...
5 Replies
The return type is automatically inferred depending on what you do in the procedure. Or does your code behave differently?
Not asking that actually. I am asking about returning dynamic
So, when I do this, it says return type is number | string
But I am trying to make it number when I provide x:true
ah, so you mean like typescript function overloads?
FAQ / Troubleshooting | tRPC
Collection of frequently asked questions with ideas on how to troubleshoot & resolve them.
okay thank youu