tRPCttRPC
Powered by
NicolasN
tRPC•3y 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
list
method:
export const organizationRouter = router({
  list: adminProcedure.query(async () => {
    const response = await listOrganizations.all();
    return response;
  }),
export const organizationRouter = router({
  list: adminProcedure.query(async () => {
    const response = await listOrganizations.all();
    return response;
  }),

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


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

const organizationData = trpc.organization.list.useQuery();  
organizationData.data <---- ANY
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?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Inference on routes & procedures
epicmau5timeEepicmau5time / ❓-help
3y ago
`useQuery` not working?
SansPapyrus683SSansPapyrus683 / ❓-help
3y ago
Quickstart not working
VilianVVilian / ❓-help
3y ago