flippyhead
flippyhead7d ago

TypeScript Type Error: Workflows Not Accessible via `internal` API

Issue When trying to reference workflows defined with workflowManager.define() through the internal API, TypeScript throws an error saying the workflow property doesn't exist, even though the code works perfectly at runtime. Code Example
// workflows/research/private.ts
import { workflowManager } from "@/src/convex/workflows";
import { internal } from "@/src/convex/_generated/api";

export const researchWorkflow = workflowManager.define({
args: { problemId: v.id("problems") },
handler: async (step, { problemId }) => {
// ... workflow logic
},
});

export const startWorkflow = internalAction({
handler: async (ctx, { problemId }) => {
// :x: TypeScript Error: Property 'researchWorkflow' does not exist
const workflowId = await workflowManager.start(
ctx,
internal.workflows.research.private.researchWorkflow, // Error here
{ problemId }
);
},
});
// workflows/research/private.ts
import { workflowManager } from "@/src/convex/workflows";
import { internal } from "@/src/convex/_generated/api";

export const researchWorkflow = workflowManager.define({
args: { problemId: v.id("problems") },
handler: async (step, { problemId }) => {
// ... workflow logic
},
});

export const startWorkflow = internalAction({
handler: async (ctx, { problemId }) => {
// :x: TypeScript Error: Property 'researchWorkflow' does not exist
const workflowId = await workflowManager.start(
ctx,
internal.workflows.research.private.researchWorkflow, // Error here
{ problemId }
);
},
});
Error Message
Property 'researchWorkflow' does not exist on type '{ startWorkflow: FunctionReference<...> }'.
Property 'researchWorkflow' does not exist on type '{ startWorkflow: FunctionReference<...> }'.
Expected Behavior TypeScript should recognize workflows defined with workflowManager.define() when accessed via internal.workflows.*.private.*, similar to how it recognizes queries, mutations, and actions. Actual Behavior - ✅ Code works at runtime - ❌ TypeScript doesn't recognize workflows through the internal API - The FilterApi type for internal only includes FunctionReference types, but workflows aren't FunctionReference types Workaround Currently using @ts-expect-error to suppress the type error:
const workflowId = await workflowManager.start(
ctx,
// @ts-expect-error - researchWorkflow exists at runtime but TypeScript doesn't see it
internal.workflows.research.private.researchWorkflow,
{ problemId }
);
const workflowId = await workflowManager.start(
ctx,
// @ts-expect-error - researchWorkflow exists at runtime but TypeScript doesn't see it
internal.workflows.research.private.researchWorkflow,
{ problemId }
);
Question Is this a known limitation, or is there a way to properly type workflows so they're recognized through the internal API? This seems like it could affect all workflows, not just this one. Thanks!
3 Replies
Convex Bot
Convex Bot7d 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!
Sara
Sara7d ago
It might be that you're not running npx convex dev to generate types during development, could you confirm that it works after running it?
flippyhead
flippyheadOP7d ago
No, I definitely am running convex dev I didn't know it was possible to use convex WITHOUT running it

Did you find this page helpful?