JSON inferred router output not matching
Hello. I have a procedure query which is returning Json from a postgresql db using Prisma. The type in the query on the server is showing up as
JsonValue
(definitions below).
The inferred type from the router.procedure.query()
on a createTRPCProxyClient
instance comes back as expected, but the type definition using inferRouterOutputs<AppRouter>
types the Json data as string | null
.
Any ideas? Thanks. New to tRPC so sorry if this is a no-brainer.
5 Replies
Have you enabled strict mode in your tsconfig? You should use it everywhere in this ecosystem
But JsonValue does declare null as a possible value there, are you sure that’s not it?
Yes I believe strict is enabled everywhere
Is that type a special class type or just a typescript type?
Hmm, I just reset my TS server and I think it's updated, my apologies.
I think it may have been Prisma creating some kind of deeply recursive type that maybe the server wasn't dealing with for whatever reason? I'm seeing
Type instantiation is excessively deep and possibly infinite.
when I try to access that value now.
So likely Prisma related and tRPC is doing everything correctly 👍
Thanks for your help and sorry for not trying that soonerOuch, that's not a good error though
Usually means Typescript can't do typechecking on that type