This behavior is likely caused by the static code generation setting being enabled in your project. When staticApi: true is set in convex.json, functions no longer have return type inference and will default to any if they don't have a returns validator. [static code generation]
Check your convex.json for this configuration:
{
"codegen": {
"staticApi": true
}
}
If that's the case, you have two options:
Option 1: Remove staticApi: true from your convex.json to restore dynamic inference.
Option 2: Add a returns validator to your function so the type is explicit even with static codegen:
import { query } from "./_generated/server";
import { v } from "convex/values";
export const test = query({
args: {},
returns: v.string(),
handler: async () => {
return "Hello, world!";
}
});
Without static codegen enabled, Convex should infer the return type automatically from the handler. If you're not using staticApi: true and still seeing any, make sure convex dev is running and has successfully completed code generation (look for the green check "Convex functions ready!" message).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: