Conversation
🦋 Changeset detectedLatest commit: 97e8bc4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit 97e8bc4
☁️ Nx Cloud last updated this comment at |
pkgs/dsl/src/dsl.ts
Outdated
| : T extends readonly (infer U)[] | ||
| ? WidenJson<U>[] |
There was a problem hiding this comment.
The WidenJson type loses the readonly modifier when widening arrays. If a handler returns a readonly array like readonly [1, 2, 3], this will be widened to a mutable number[], breaking type safety.
Fix: Preserve the readonly modifier:
: T extends readonly (infer U)[]
? readonly WidenJson<U>[]
: T extends objectThis ensures readonly arrays remain readonly after widening.
| : T extends readonly (infer U)[] | |
| ? WidenJson<U>[] | |
| : T extends readonly (infer U)[] | |
| ? readonly WidenJson<U>[] |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
211672e to
86a8ccf
Compare
01544a2 to
cffe9d0
Compare
cffe9d0 to
aaf742e
Compare
Step handler return types were validated through EnforceJsonOutput but stored as raw AwaitedReturn<THandler> in StepMeta. This mismatch caused CompatibleFlow and EdgeWorker.start overloads to collapse to never when step handlers returned interface types (e.g. DTOs), because the stored metadata didn't match the JSON-normalized shape used by downstream type inference. Normalize all three flow method metadata paths to store JsonCompatible variants of the handler output, matching the existing validation layer: - .step(): store JsonCompatible<AwaitedReturn<THandler>> instead of raw AwaitedReturn<THandler> across all six overloads - .array(): store JsonCompatible<Awaited<TOutput>> and enforce JSON compatibility at the handler return boundary - .map(): store JsonCompatible<AwaitedReturn<THandler>>[] with EnforceJsonOutput handler validation Also fix JsonCompatible to preserve tuple structure (previously widened tuples to generic arrays), and add regression type tests for interface DTO step outputs with dependent steps and EdgeWorker.start acceptance.
aaf742e to
97e8bc4
Compare
🔍 Preview Deployment: Website✅ Deployment successful! 🔗 Preview URL: https://pr-615.pgflow.pages.dev 📝 Details:
_Last updated: _ |
🚀 Production Deployment: Website✅ Successfully deployed to production! 🔗 Production URL: https://pgflow.dev 📝 Details:
Deployed at: 2026-03-20T16:48:45+01:00 |

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
Jsontype constraint on step handler return values, preventing non-serializable types likeundefined,Symbol, or functions from being returned. A newWidenJson<T>utility type is added to properly widen literal types (e.g.,123becomesnumber) while maintaining JSON compatibility.All six
.step()method overloads are updated to use a constrainedTHandlertype parameter instead of a genericTOutput, ensuring type safety at compile time. Comprehensive type tests verify that valid JSON types are accepted while invalid types likeundefinedand functions are properly rejected with TypeScript errors.