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: af7d04a

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 af7d04a

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 51s View ↗
nx run core:pgtap ✅ Succeeded <1s View ↗
nx run edge-worker:e2e ✅ Succeeded 40s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 4s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 3s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 2m 25s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-11 19:39:05 UTC

@jumski jumski force-pushed the 01-06-add_stepmeta_type_structure_for_skippable_deps_tracking branch from 14ed89d to af7d04a Compare January 11, 2026 19:26
@jumski jumski force-pushed the 01-06-add_containmentpattern_t_type_for_type-safe_condition_options_in_dsl branch from 2b3cca7 to 966c7d1 Compare January 11, 2026 19:26
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