Type Issue with gameId in Convex Query
Hi, I have an issue with TypeScript types in Convex.
I'm looking at the example code in the Fast5 repo:
In the Fast5 repo, gameId has the proper type:
However, when I use the exact same code in my repo, the type of gameId is inferred as:
I’m wondering why this is happening. Could this be related to TypeScript configuration, Convex version differences, or something else?
Any help would be appreciated! Thanks! 😊
44 Replies
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!
withUser wrapper is the same as in Fast5 repo
Usually this is because of a typescript error in another file
Thanks for the response! I checked the Convex logs, and I'm seeing:
I don’t see any TypeScript errors in the logs.
Could there be another reason why
I don’t see any TypeScript errors in the logs.
Could there be another reason why
gameId
is inferred as any
?One function having circular inference and therefore inferring any can make lots of types be any. When you say exact same code, do you have the same libraries installed, is this just a copy of that repo? Or you have your own code too?
Somewhere you have a type that can't be inferred, or some types that are broken (but apparently not in a way that causes a type error)
while building i did got one errror can this be the case?
ah it looks like a Next.js typecheck failed?
Someone fixed this issue yesterday by adding
downlevelIteration
to their convex/tsconfig.json, but there's something we'll need to figure out here.Ok, will try and get back to you.
Can you share your code for the any issue? Would help to see more examples
Example function with wrapper:
The withUser is copied from fast5 repo:
Build with the downlevelIteration as true is still failing:
my convex/tsconfig.ts
My next.js version is 14.2.7 and node 22.13.1
So I updated dependencies and cleared cache and the problem is no longer appearing but the args still have type any
@Robert sorry, I should have been more specific. Could you share all the code, as a GitHub repo? Often the problem is not just with one file, it's an
any
in another file that causes a propagation of any
types via the schema or api object types.
We'll see an any
coming from somewhere if we look through all the filesSure, I can share the code, but not publicly. Let me know how you'd like to proceed—DM with link or adding you to a private repo?
Sure, you can add me, GitHub handle is thomasballinger. I'l write up my method to add it to the docs
feel free to email tom@convex.dev
or support@convex.dev
ok i will add you in a sec
I've sent an invite
@Robert what file do you see this issue in?
I don't see a gameId
convex/PROJECT_FUNCTIONS/applications.ts
the gameId was an example that this happends even if i do it on the 1:1 example from fast5 repo
I can't find one tha'ts a problem, what's a line where you see an issue?

what package manager do you use, I see yarn.lock and a package-lock.json
line 16
I use yarn


tried with yarn too, same thing
hm do you have missing dependnecies, what version of TypeScript are you using?
you want to track down where an
any
is coming from, perhaps from an import
you might want to use strict mode in TypeScript
strict mode highlights anys much moreI see that you are showing the userId type which is fine with displaying but i am talking about in - args are type
what line number?
based on this screen the line 14
You might not have pushed recently, I don't see any
withUser
I forgot to say that this is on dev branch, sorry
ah ok I see it now
your zod validator seems convertible

so nothing's sticking out yet
I'll get back to think in a few min
so the zod stuff is fine without
withUser

@Robert you said you copied this fancy
withUser
thing from Fast5? That's pretty old codelast updated 2 years ago

The way we do this today is with custom functions, https://github.com/get-convex/convex-helpers/blob/main/packages/convex-helpers/README.md#custom-functions
GitHub
convex-helpers/packages/convex-helpers/README.md at main · get-conv...
A collection of useful code to complement the official packages. - get-convex/convex-helpers
Ok i will recreate the withUser using custom functions and see if this will work
all of this got rewritten when we added argument validators
I think that's what you're running into
withUser is mentioned here https://stack.convex.dev/custom-functions
Customizing serverless functions without middleware
Re-use code and centralize request handler definitions with discoverability and type safety and without the indirection of middleware or nesting of wr...
another option is not doing this, and writing a helper function that you use like
const currentUser = await getCurrentUser(ctx)
but since it's just code, you can get fancy with it if you want, that's what custom functions are
but the TypeScript is pretty fancy, personally I prefer calling helper functionsok, i see. I will try with custom functions, i think this will work perfectly. Thanks for help and getting through my messy code 😄
I think there might be another version of custom functions specifically for the zod thingyou're doing
ah it's called
zCustomFunction
https://stack.convex.dev/typescript-zod-function-validationThat's good to know, will try
something like this

Now it is working!
Sharing a zMutationWithUser example in case someone encounters a similar issue in the future
Thanks for help!