Bas Dijkstra
06/05/2026, 9:24 AM'an address with ID {addressId} does not exist': async (params?: { [name: string]: string }) => {
const addressId = params?.['addressId'];
if (!addressId) throw new Error('addressId param is required');
removeAddress(addressId);
},
This works, and I see that the params object contains the proper values. However, VS Code tells me:
Type '(params?: { [name: string]: string; }) => Promise<void>' is not assignable to type 'StateHandler & ((state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>)'.
Type '(params?: { [name: string]: string; }) => Promise<void>' is not assignable to type 'StateFuncWithSetup & ((state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>)'.
Type '(params?: { [name: string]: string; }) => Promise<void>' is not assignable to type '(state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>'.
Types of parameters 'params' and 'state' are incompatible.
Type 'string' is not assignable to type '{ [name: string]: string; }'.
If I update the handler signature to
'an address with ID {addressId} does not exist': async (state: string, params?: { [name: string]: string }) => {
state obviously now contains the provider state parameters, and params is undefined. I'm not a TS expert but doesn't that mean there's something wrong with the type definitions? Or am I missing an explicit type definition package in my project maybe? All I'm using is "@pact-foundation/pact": "^16.5.0".Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
types are exported in this package, so you shouldn’t need to import any additional ones. We did recently update a type definition, but I think that was for messages. But it’s possible it’s a type def problemobviously now contains the provider state parameters, andstateisparams. I’m not a TS expert but doesn’t that mean there’s something wrong with the type definitions? Or am I missing an explicit type definition package in my project maybe? All I’m using isundefined."@pact-foundation/pact": "^16.5.0"
Bas Dijkstra
06/09/2026, 10:06 AMMurat Ozcan
06/10/2026, 12:34 PMimport {
buildVerifierOptions,
type StateHandlers,
} from '@seontechnologies/pactjs-utils';
const stateHandlers: StateHandlers = {
'an address with ID {addressId} does not exist': async (params) => {
const addressId = params?.addressId;
if (!addressId) throw new Error('addressId param is required');
removeAddress(addressId);
},
}
const opts = buildVerifierOptions({
provider: 'your-provider',
port: '3000',
includeMainAndDeployed: true,
stateHandlers,
})
It also helps remove a bunch of the usual Pact verifier boilerplateBas Dijkstra
06/10/2026, 1:35 PMMatt (pactflow.io / pact-js / pact-go)