Static code generation <> WorkflowId
I have a project that is growing in lines of code. I am following all recommended convex practices of keeping all my functions strictly typed to minimise how much type inference typescript needs to make, but it still reached the point where it's becoming just too slow to work comfortably.
I found the Static code generation section in the docs (https://docs.convex.dev/production/project-configuration#using-static-code-generation-beta) which looks like exactly what I need. I tried it out and for the most part it works perfectly.
There is however an issue when paired with
@convex-dev/workflow. Code generation does not work as expected for the vWorkflowId validator. I am typing my schema as follows:
When I try to query this table without SCG, the type is as expected:
However, with SCG the type becomes a string:
As far as I can tell this make it unusable at the moment because I have type errors in all places where I use the vWorkflowId validator and the WorkflowId type. Since this type is coming directly from ctx.db.query I am not sure how to work around it. Note that this issue is observed also in convex function arguments, which makes it impossible to correctly pass a function handler in the onComplete callback of workflows, since the onComplete expects workflowId: vWorkflowId but the resulting type from a function this argument resolves to workflowId: string after the Static Code Generation.
Overall this feature is very much needed as codebases are becoming larger, this is the only issue I observed so far that is preventing me from using it.Project Configuration | Convex Developer Hub
Configure your Convex project for development and production deployment using convex.json, environment variables, and deployment settings.
1 Reply
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!