flippyheadF
Convex Community4mo ago
4 replies
flippyhead

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 }
    );
  },
});


Error Message

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 }
);


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!
Was this page helpful?