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