ragokan
ragokan15mo ago

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:
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. ...
Jump to solution
5 Replies
Michael Schaufelberger
The return type is automatically inferred depending on what you do in the procedure. Or does your code behave differently?
ragokan
ragokan15mo ago
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
Michael Schaufelberger
ah, so you mean like typescript function overloads?
Martin
Martin15mo ago
FAQ / Troubleshooting | tRPC
Collection of frequently asked questions with ideas on how to troubleshoot & resolve them.
ragokan
ragokan15mo ago
okay thank youu