Skip to main content
OpenWorkflow uses schemas or explicit types to type workflow inputs and outputs. Step result types are inferred from their functions’ return values. These types provide autocomplete and compile-time checking throughout.

Schema Validation with Type Inference

For runtime validation with type inference, use Standard Schema compatible libraries like Zod:
With a schema and no explicit generics, the input type comes from the schema and the output type is inferred from the workflow function’s return value. Here, the output is { recipient: string; amount: number }.

Explicit Type Definitions

To manually specify input and output types, use both generics with defineWorkflow. Generics provide compile-time checking; use a schema if you also need runtime input validation. This example uses your application’s validateOrder and shipOrder functions. Follow the Quick Start for a runnable example with setup instructions.
If you supply only the input generic, as in defineWorkflow<{ name: string }>(...), the workflow’s output type is unknown, so handle.result() returns Promise<unknown>. Supply both input and output types when you need a typed result without a schema:

Workflow Specs

When using defineWorkflowSpec for separate declaration and implementation, types flow through:

Client-Side Type Safety

When you run a workflow, the handle is typed with the output:

Step Result Types

Step return types are inferred automatically, even when you supply only the workflow’s input generic: