rdR
tRPC3y ago
10 replies
rd

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.

type JsonObject = { [Key in string]?: JsonValue };
interface JsonArray extends Array<JsonValue> {}
type JsonValue = string | number | boolean | JsonObject | JsonArray | null;
Was this page helpful?