stu
stu2mo ago

procedure output is "any"

I have a problem with the procedure output type. Procedure input types are all correct, but the output type is "any." The server type is correct, but not on inferRouterClient<AppRouter> I'm using 11.0.0-rc.648 and zod ^3.23.8 here's what I got inferRouterClient<AppRouter>
type Client = {
register: {
mutate: Resolver<{
input: {
name: string;
email: string;
password: string;
};
output: any;
errorShape: DefaultErrorShape;
transformer: false;
}>;
};
login: {
...;
};
... 22 more ...;
candidateDocuments: {
...;
};
}
type Client = {
register: {
mutate: Resolver<{
input: {
name: string;
email: string;
password: string;
};
output: any;
errorShape: DefaultErrorShape;
transformer: false;
}>;
};
login: {
...;
};
... 22 more ...;
candidateDocuments: {
...;
};
}
register procedure
export const register = publicProcedure
.input(
z.object({
name: z.string(),
email: z.string(),
password: z.string(),
})
)
.output(z.boolean())
.mutation(async ({ input: { name, email, password } }) => {
// ------
});
export const register = publicProcedure
.input(
z.object({
name: z.string(),
email: z.string(),
password: z.string(),
})
)
.output(z.boolean())
.mutation(async ({ input: { name, email, password } }) => {
// ------
});
14 Replies
stu
stuOP2mo ago
i guess this is a bug?
Alex / KATT 🐱
FAQ / Troubleshooting | tRPC
Collection of frequently asked questions with ideas on how to troubleshoot & resolve them.
stu
stuOP2mo ago
yes, i read that article before, and I'm still getting "any" tsconfig.json
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
package.json
...
"dependencies": {
...
"@trpc/client": "11.0.0-rc.648",
"@trpc/server": "11.0.0-rc.648",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5.6.3"
}
}
...
"dependencies": {
...
"@trpc/client": "11.0.0-rc.648",
"@trpc/server": "11.0.0-rc.648",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5.6.3"
}
}
i guess something to do with ts Serialize i try Serialize<{ a: number }> got any I also got this error inside Serialize
Generic type 'AsyncIterable<T>' requires 1 type argument(s).ts(2314)
Generic type 'AsyncIterable<T>' requires 1 type argument(s).ts(2314)
Alex / KATT 🐱
Bump typescript "Make sure you are using the TypeScript-version required by tRPC (>=5.6.2)"
TechnoWill
TechnoWill2w ago
I'm getting this as well Bumped TS to 5.7 and still having issues @stu looking deeper I've also got the issue with AsyncIterable - it doesn't seem to like infer So it was only that the TS version meant that you can remove the final two type args but that doesn't fix it Tried messing around with versions (was on v11 - downgraded to v10) no luck AH OK The downgrade worked - if you downgrade to v10 and downgrade TS to the appropriate version then delete and reinstall your node_modules , I've got mine back It's working
Alex / KATT 🐱
Read this @TechnoWill, was likely that your vscode/cursor wasn't configured to the latest ts version if it was a v11 issue
TechnoWill
TechnoWill2w ago
I did do that and reset it - but willing to assume that it's my local env lol Will probably figure out again if I can dedicate more time to it
Wulfie
Wulfie2w ago
[edit 2: see potential fix below] [edit as i've made a simpler version with just a single healthcheck function] New to this so apologies if better to post elsewhere! But to confirm that i'm getting this same issue (incl. trying all the troubleshooting steps above) and i don't think it's a setup thing as client typing is working perfectly except output typings. using react query integration on client and fastify on server, versions: "@trpc/client": "^11.0.0-rc.682", "@trpc/react-query": "^11.0.0-rc.682", "@trpc/server": "^11.0.0-rc.682", "typescript": "^5.7.2" Pics 1 & 2 are server: show healthcheck procedure output is correctly typed as string Pic 3 is instantiation in client, correctly typed as string output Pic 4: healthcheck has lost the typing Any questions just let me know 🙂
No description
No description
No description
No description
Wulfie
Wulfie2w ago
[Edit] - ignore below, it was indeed Cursor not picking up TS changes until hardcoding TS version into settings. Followup: I think i've found a possible solution If I locally change node_modules/@trpc/react-query/dist/createTRPCReact.d.ts type DecorateRouterRecord output type from inferTransformedProcedureOutput<TRoot, $Value> to inferProcedureOutput<$Value>; the error is resolved and i get the right type inferred (see pic 1). It also seems to match the type you use above (i.e. the input isn't called transformed, whilst the output was)
No description
No description
No description
Alex / KATT 🐱
This issue was still most likely that your editor wasn't using the latest ts version
Wulfie
Wulfie2w ago
Sadly for past me, you're right, so thank you - Cursor wasn't picking up any of the TS changes until I manually hardcoded some settings. Thanks for the patience (and at least i now know more about tRPC under the hood)
Alex / KATT 🐱
Could you please be a hero and make an issue over in cursor issue tracker and ask them to bump their default version? Everyone using trpc will have the issue
Wulfie
Wulfie2w ago
Will do, cheers!

Did you find this page helpful?