NicolasN
tRPC3y ago
3 replies
Nicolas

Basic Inference not Working

I have been struggling to get basic type inferencing to work with trpc, react, and Drizzle ORM.

This is what my server-side router is returning from the list method:
export const organizationRouter = router({
  list: adminProcedure.query(async () => {
    const response = await listOrganizations.all();
    return response;
  }),

Where, if I hover over the response in the return, it says the type is:
const response: {
    id: number;
    name: string;
    description: string | null;
}[]


However, on my client side, it says the type is
any
for the following:

const organizationData = trpc.organization.list.useQuery();  
organizationData.data <---- ANY


Why is this basic type inferencing not happening?

I am using Drizzle ORM to infer the return type on the router response; could this have something to do with it?

Does trpc not work well with ORM's that use inference?
Was this page helpful?