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