Kranga
Kranga12mo ago

Procedure return types are getting inferred as any

Hi, I just created a prisma + trpc backend which uses prisma-trpc-generator to generate trpc routers from the prisma schema. I noticed that while procedure parameters are correctly typed the return type is not getting inferred. This is not a monorepo-related issue since I moved my client to the server directory and the return types are inferred as TProcedure["_def"]["_config"]["transformer"] extends DefaultDataTransformer ? Serialize<TProcedure["_def"]["_output_out"]> : TProcedure["_def"]["_output_out"], a type that despite not being any behaves exactly like any, not providing any type-checks or autocompletion. Is there any tsconfig that "just works" for trpc? I have spent so much time fiddling with my tsconfig.json and can't get it to work.
2 Replies
Kranga
Kranga12mo ago
This is my current tsconfig trying everything I found online to try to make it work { "ts-node": { "require": ["tsconfig-paths/register"] }, "compilerOptions": { "composite": true, "target": "ESNext", "lib": ["esnext"], "allowJs": true, "checkJs": true, "skipLibCheck": false, "strict": true, "module": "ESNext", "moduleResolution": "bundler", "baseUrl": ".", "resolveJsonModule": true, "isolatedModules": true, "incremental": true, "esModuleInterop": true, "noUncheckedIndexedAccess": true, "declaration": true, "declarationMap": true, "paths": { "#trpc": ["./trpc.js"], "#db": ["./prisma/db.js"], "#constants": ["./constants.js"], }, }, "include": ["./*\*/\*"], "references": [ {"path": "../front"} ], "exclude": ["node_modules", "types"] }
DiamondDragon
DiamondDragon10mo ago
did you find a solution? @Kranga I am getting not getting type safety on a rute like this, its typed as any
export const signupRouter = router({
signupNewTeam: publicProcedure
.input(insertSignupNewTeam)
.mutation(async opts => {
return await createSignupService(opts.ctx.database).signupNewTeam(
opts.input,
)
}),
export const signupRouter = router({
signupNewTeam: publicProcedure
.input(insertSignupNewTeam)
.mutation(async opts => {
return await createSignupService(opts.ctx.database).signupNewTeam(
opts.input,
)
}),