Skip to content

fix(verifier): accept lifecycle state handlers - #1876

Open
KSHITIZ6341 wants to merge 1 commit into
pact-foundation:masterfrom
KSHITIZ6341:fix/verifier-state-handler-types
Open

fix(verifier): accept lifecycle state handlers#1876
KSHITIZ6341 wants to merge 1 commit into
pact-foundation:masterfrom
KSHITIZ6341:fix/verifier-state-handler-types

Conversation

@KSHITIZ6341

Copy link
Copy Markdown
Contributor

What this changes

VerifierOptions currently intersects ProxyOptions with Partial<MessageProviderOptions>. Both types declare stateHandlers with different call signatures, so TypeScript requires every verifier state handler to satisfy both the HTTP and message-provider forms. That rejects the supported { setup, teardown } lifecycle form.

This removes the redundant MessageProviderOptions intersection because ProxyOptions already carries logLevel, messageProviders, and the HTTP verifier stateHandlers. It also lets state handlers resolve without a value, matching their existing optional provider-state injection behaviour, and derives the internal setupStates return type from StateFunc.

The change is type-compatible and does not alter verifier runtime behaviour. Existing function handlers and handlers returning provider-state values remain supported.

Credit to @ghost91- for the minimal failing example, @valkolovos for tracing the conflict to the overlapping declarations, and @muratkeremozcan for supplying a standalone reproduction.

Fixes #1164

Verification

  • Confirmed the regression test fails on master with TS2418 before the fix.
  • biome format (228 files)
  • biome lint (228 files)
  • tsc --noEmit
  • vitest run (28 files, 284 tests; coverage thresholds passed)
  • Distribution build via rimraf dist, tsc, and copyfiles package.json ./dist
  • Regression consumers (14 files, 40 passed, 2 skipped)
  • Regression providers (9 files, 11 passed)
  • git diff --check

No practical local test suite was omitted. The repository CI operating-system and Node.js version matrix remains to run.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.06%. Comparing base (7c332cb) to head (910c600).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1876   +/-   ##
=======================================
  Coverage   61.06%   61.06%           
=======================================
  Files          67       67           
  Lines        4187     4187           
  Branches      352      352           
=======================================
  Hits         2557     2557           
  Misses       1628     1628           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

TypeScript error when trying to provide a stateHandler with setup and teardown

2 participants