mh
mh
TtRPC
Created by mh on 10/18/2024 in #❓-help
Types issues upgrading to v11, `never` when using t.router
Weird thing is, if I use initTrpc directly in the api project in the exact same way as in the shared project, the types start working.
import { Context, procedure } from "trpc-server-shared";
import { initTRPC, type inferRouterInputs } from "@trpc/server";

const t = initTRPC.context<Context>().create();
// don't use router from shared package, note t.router. procedure can still be from shared package
export const appRouter = t.router({
health: t.router({ check: procedure.query(() => ({ healthy: "ok" })) })
});

type AppRouter = typeof appRouter;
type AppRouterInputs = inferRouterInputs<AppRouter>;
import { Context, procedure } from "trpc-server-shared";
import { initTRPC, type inferRouterInputs } from "@trpc/server";

const t = initTRPC.context<Context>().create();
// don't use router from shared package, note t.router. procedure can still be from shared package
export const appRouter = t.router({
health: t.router({ check: procedure.query(() => ({ healthy: "ok" })) })
});

type AppRouter = typeof appRouter;
type AppRouterInputs = inferRouterInputs<AppRouter>;
Now AppRouterInputs has correct typing instead of never We are using typescript 5.6.2, node v22.9.0, pnpm v9.12.0 and have sctrict: true, also have
"declaration": true,
"declarationMap": true,
"declaration": true,
"declarationMap": true,
2 replies