winsoroaks
winsoroaks3w ago

Type Inference Lint Errors When Returning Mutation Result in Internal Action

I'm encountering a TypeScript linting issue inside an internal action function. Here’s a simplified version of the function signature:
export const doSomethingAction = internalAction({
args: {
userId: v.id("users"),
// ...other args
},
handler: async (ctx, args) => {
// ...logic
const result = await ctx.runMutation(internal.someModule.someMutation, {
// ...args
});
return result;
},
});
export const doSomethingAction = internalAction({
args: {
userId: v.id("users"),
// ...other args
},
handler: async (ctx, args) => {
// ...logic
const result = await ctx.runMutation(internal.someModule.someMutation, {
// ...args
});
return result;
},
});
When I assign the result of ctx.runMutation to a variable (e.g., const result = ...) and return it, I get a series of "implicitly has type 'any'" linter errors for the result and related variables. However, if I remove the assignment and the return statement (i.e., I don't assign or return the mutation result), the lint errors disappear. Why does returning the result of ctx.runMutation in an internal action trigger these implicit 'any' type errors, and is there a recommended way to resolve this while still returning the mutation result?
2 Replies
Convex Bot
Convex Bot3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart2w ago
It’s circular inference. Here’s how to deal with it: https://docs.convex.dev/functions/actions#dealing-with-circular-type-inference

Did you find this page helpful?