Dynamic branching: inspects the state accumulated so far and returns the
builder to continue with. Unlike skip, this can add an entirely
different set of steps per branch rather than just omitting one.
When different branches add disjoint keys (e.g. featureName vs.
bugId), TypeScript can't infer — or even check — a single S2 from a
function returning a union of differently-keyed WizardBuilders
(WizardBuilder is invariant in its state parameter, since
step()/optionalStep() also consume it contravariantly). Give S2
explicitly and cast the union through unknown.
Branches that share their key set don't need either.
Adds a step that may be skipped based on the state so far — its result
type is optional (key?: V) since the wizard may complete without ever
asking it.
Runs the wizard.
Result.ok with the fully-typed state on completion, or
Result.err (with cancelled: true) holding the step key the user
cancelled at and the partial state gathered so far. Unexpected
errors from step callbacks reject the promise as a
WizardStepError instead of resolving — see that class.
Adds a required step. key must not already be used by an earlier
step (enforced at compile time).
Type-accumulating fluent builder for multi-step wizards. Each
.step()/.optionalStep()call folds its value's type into the state type carried by the chain, sorun()resolves with an exact, cast-free result type —.step()fields are required,.optionalStep()fields are optional exactly when theirskippredicate could make them so.Build steps with quickpickStep/inputStep; obtain a builder with
wizard().