t
tRPC
t
tRPC
Get inferred type from a procedure which has conditional Select query
Original message was deleted
tRPC
Join
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,111
Members
View on Discord
N
Nick
•
3/21/23, 10:00 AM
You just need to narrow or discriminate the type at runtime and typescript will understand
N
Nick
•
3/21/23, 10:01 AM
Same problem as here
:
❓-help
Cannot infertype of prisma in client
N
Nick
•
3/21/23, 10:30 AM
By
“select
” do you mean you want to do something like Zod does with
.pick and
.omit
?
N
Nick
•
3/21/23, 10:30 AM
That might not be possible in tRPC
N
Nick
•
3/21/23, 10:31 AM
Best to just make it an optional field and then check if it
’s set in the response
N
Nick
•
3/21/23, 10:31 AM
This does decouple your presentation from your query which has advantages