James Hopgood
James Hopgood5h ago

TS error regarding inferred type of 'appRouter'

Hey there, I've been running into this issue with my turborepo. I have an api (hono) backend and a nextjs frontend and both rely on tRPC in order to function/make calls. I believe this is an issue with trpc/server and zod? But honestly everything I find online isn't quite right. I have a pretty standard setup that I think I have used before with no issues. I use Zod in multiple places in my repo but I make sure that they are all the same version. I'm not 100% sure of which code to show so please do ask for anything you need to see in the comments. - Node 22 - Bun - Turborepo - @trpc/server 11.5.1 - zod 4.1.5
The inferred type of 'appRouter' cannot be named without a reference to '../../../../node_modules/zod/v4/core/util.d.cts'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'appRouter' cannot be named without a reference to '../../../../node_modules/zod/v4/core/util.d.cts'. This is likely not portable. A type annotation is necessary.ts(2742)
import type { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
import { router } from "../alt";

export const appRouter = router({...})
import type { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
import { router } from "../alt";

export const appRouter = router({...})
import { TRPCError, initTRPC } from "@trpc/server";
import superjson from "superjson";
import type { Context } from "./context";

const t = initTRPC.context<Context>().create({
transformer: superjson,
errorFormatter({ shape }) {
return shape;
},
});

const isAuthed = t.middleware(({ next, ctx }) => {
if (!ctx.auth?.userId) {
throw new TRPCError({ code: "UNAUTHORIZED", message: "Not authenticated" });
}
return next({
ctx: {
...ctx,
auth: ctx.auth,
},
});
});

export const router = t.router;
export const publicProcedure = t.procedure;
export const protectedProcedure = t.procedure.use(isAuthed);
import { TRPCError, initTRPC } from "@trpc/server";
import superjson from "superjson";
import type { Context } from "./context";

const t = initTRPC.context<Context>().create({
transformer: superjson,
errorFormatter({ shape }) {
return shape;
},
});

const isAuthed = t.middleware(({ next, ctx }) => {
if (!ctx.auth?.userId) {
throw new TRPCError({ code: "UNAUTHORIZED", message: "Not authenticated" });
}
return next({
ctx: {
...ctx,
auth: ctx.auth,
},
});
});

export const router = t.router;
export const publicProcedure = t.procedure;
export const protectedProcedure = t.procedure.use(isAuthed);
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?