Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Jan 8, 2026

Add Type Safety for Skippable Step Dependencies

This PR enhances the Flow DSL's type system to properly handle skippable steps. When a step has whenUnmet: 'skip' or whenFailed: 'skip', dependent steps now receive that step's output as an optional property in their dependencies object.

Key improvements:

  • Added a StepMeta interface to track both output type and skippability status
  • Modified StepInput to make dependencies optional when they come from skippable steps
  • Added comprehensive type tests to verify correct behavior in various scenarios
  • Ensured type narrowing works properly after existence checks

This change improves type safety by preventing runtime errors when accessing potentially undefined outputs from skipped steps. Developers will now get proper TypeScript errors if they try to access properties on skippable dependencies without first checking for their existence.

Example usage:

flow.step({ slug: 'risky', whenFailed: 'skip' }, () => ({ result: 42 }))
    .step({ slug: 'dependent', dependsOn: ['risky'] }, (deps) => {
      // TypeScript now requires a null check before accessing properties
      if (deps.risky) {
        return { value: deps.risky.result };
      }
      return { value: 0 };
    });

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

⚠️ No Changeset found

Latest commit: bdabd07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Jan 8, 2026

View your CI Pipeline Execution ↗ for commit bdabd07

Command Status Duration Result
nx run cli:e2e ✅ Succeeded 4s View ↗
nx run edge-worker:test:integration ✅ Succeeded 5m 17s View ↗
nx run core:pgtap ✅ Succeeded 26s View ↗
nx run client:e2e ✅ Succeeded 2m 52s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 4s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 4s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 1m 54s View ↗
nx run edge-worker:e2e ✅ Succeeded 42s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-14 08:02:37 UTC

@jumski jumski force-pushed the 01-06-add_stepmeta_type_structure_for_skippable_deps_tracking branch from af7d04a to bdabd07 Compare January 14, 2026 07:52
@jumski jumski force-pushed the 01-06-add_containmentpattern_t_type_for_type-safe_condition_options_in_dsl branch from 966c7d1 to 5db1a76 Compare January 14, 2026 07:52
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.

2 participants