T

tRPC

❓-help

Join Server

createTRPCNext type error

MMoronPenguin4/25/2023
Hi everyone. So I started creating nextjs app with trpc + prisma set up. and when i use my AppRouter type with createTRPCNext I get "The types returned by createCaller(...) are incompatible between these types." error
Type 'CreateRouterInner<RootConfig<{ ctx: { user: User | null; prisma: PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>, { ...; }>' does not satisfy the constraint 'Router<AnyRouterDef<AnyRootConfig, any>>'.
  The types returned by 'createCaller(...)' are incompatible between these types.
    Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: { user: User | null; prisma: PrismaClient<...>; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>, { ...; }>; user: CreateRouter...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
      Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: { user: User | null; prisma: PrismaClient<...>; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>, { ...; }>; user: CreateRouter...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
        Types of property 'query' are incompatible.
          Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
            Types of parameters 'path' and 'path' are incompatible.
              Type 'TPath' is not assignable to type 'never'.
                Type 'string' is not assignable to type 'never'.

this is whole error msg and I'm not sure if you guys have seen it!
Nnlucas4/25/2023
Are all your tRPC package versions the same version?
Nnlucas4/25/2023
They must all match
MMoronPenguin4/25/2023
Holy crap. U were right my server-side was 10.21.0 and client side was 10.21.1 and when I updated server it works find. 💪🏻 thank you!
Nnlucas4/25/2023
Second time I’ve seen it this week 😅
Sshu5/19/2023
Hi, im having the same error expect my versions are all 10.20.0