Skip to content

feat: enforce JSON-compatible step outputs at construction time#615

Merged
jumski merged 1 commit intomainfrom
03-19-enforce_json-safe_step_outputs_without_narrowing_inference
Mar 20, 2026
Merged

feat: enforce JSON-compatible step outputs at construction time#615
jumski merged 1 commit intomainfrom
03-19-enforce_json-safe_step_outputs_without_narrowing_inference

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Mar 19, 2026

This pull request enforces JSON-compatible step outputs at .step() construction time by adding TypeScript constraints to the step handler functions.

The changes introduce a Json type constraint on step handler return values, preventing non-serializable types like undefined, Symbol, or functions from being returned. A new WidenJson<T> utility type is added to properly widen literal types (e.g., 123 becomes number) while maintaining JSON compatibility.

All six .step() method overloads are updated to use a constrained THandler type parameter instead of a generic TOutput, ensuring type safety at compile time. Comprehensive type tests verify that valid JSON types are accepted while invalid types like undefined and functions are properly rejected with TypeScript errors.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant