<#1120 fix: `stateHandlers` type in `VerifierOptio...
# pact-js-development
g
#1120 fix: `stateHandlers` type in `VerifierOptions` Pull request opened by ben-styling ☑︎
npm run dist
works locally (this will run tests, lint and build) ☑︎ Commit messages are ready to go in the changelog (see below for details) ☑︎ PR template filled in (see below for details) Summary This PR fixes the
stateHandlers
property on
VerifierOptions
by making the
stateHandlers
on
MessageStateHandlers
a generic type, which is set as
unknown
in the
MessageProviderOptions
type. This issue is described in #1057, and marked as fixed in #1062, but the type issue still persists in v`12.1.0` When using the following:
Copy code
stateHandlers: {
  'some state': {
    setup: async () => {},
    teardown: async () => {},
  }
}
The following TS error is present
Copy code
Type '{ setup: () => Promise<void>; teardown: () => Promise<void>; }' provides no match for the signature '(state: string, params?: { [name: string]: string; } | undefined): Promise<unknown>'.ts

image▾

I'm not very familiar with pact yet, this might be a breaking change as the
MessageStateHandlers
is exposed. Would love to know if there's a better way to do this! pact-foundation/pact-js Cirrus CI: macos_arm NODE_VERSION:18 Cirrus CI: macos_arm NODE_VERSION:16 Cirrus CI: linux_arm arm_containernode18-slim Cirrus CI: linux_arm arm_containernode16-slim Cirrus CI: macos_arm NODE_VERSION:20 Cirrus CI: linux_arm arm_containernode20.2-slim ✅ 1 other check has passed 1/7 successful checks