@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Interface WizardBuilder<S>

    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, so run() resolves with an exact, cast-free result type — .step() fields are required, .optionalStep() fields are optional exactly when their skip predicate could make them so.

    Build steps with quickpickStep/inputStep; obtain a builder with wizard().

    interface WizardBuilder<S> {
        branch<S2>(
            fn: (state: Readonly<S>) => WizardBuilder<S2>,
        ): WizardBuilder<S & S2>;
        optionalStep<K extends string, V>(
            key: K extends keyof S ? never : K,
            def: StepDefinition<S, V>,
            opts: { skip: (state: Partial<S>) => boolean; title?: string },
        ): WizardBuilder<S & Partial<Record<K, V>>>;
        run(
            options: WizardRunOptions,
        ): Promise<Result<S, { atKey: keyof S | null; state: Partial<S> }>>;
        step<K extends string, V>(
            key: K extends keyof S ? never : K,
            def: StepDefinition<S, V>,
            opts?: { title?: string },
        ): WizardBuilder<S & Record<K, V>>;
    }

    Type Parameters

    • S
    Index
    • 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.

      Type Parameters

      • S2

      Parameters

      Returns WizardBuilder<S & S2>

    • 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.

      Type Parameters

      • K extends string
      • V

      Parameters

      • key: K extends keyof S ? never : K
      • def: StepDefinition<S, V>
      • opts: { skip: (state: Partial<S>) => boolean; title?: string }

      Returns WizardBuilder<S & Partial<Record<K, V>>>

    • Runs the wizard.

      Parameters

      Returns Promise<Result<S, { atKey: keyof S | null; state: Partial<S> }>>

      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.