GitHub
02/07/2023, 5:31 PM(property) 'my state': {
setup: () => Promise<void>;
teardown: () => Promise<void>;
}
Type '{ setup: () => Promise<void>; teardown: () => Promise<void>; }' is not assignable to type 'StateHandler & ((state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>)'.
Type '{ setup: () => Promise<void>; teardown: () => Promise<void>; }' is not assignable to type 'StateFuncWithSetup & ((state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>)'.
Type '{ setup: () => Promise<void>; teardown: () => Promise<void>; }' is not assignable to type '(state: string, params?: { [name: string]: string; } | undefined) => Promise<unknown>'.
Type '{ setup: () => Promise<void>; teardown: () => Promise<void>; }' provides no match for the signature '(state: string, params?: { [name: string]: string; } | undefined): Promise<unknown>'.ts(2322)
Steps to reproduce
Create a state handler definition such as:
'Whatever your state name is': {
setup: (parameters) => {
// do your setup here
// return a promise if you need to
},
teardown: (parameters) => {
// do your teardown here
// return a promise if you need to
},
},
TS will complain as above.
As a workaround, we've created a shim type. An alternative as mentioned by @Timothy Jones in the slack thread is to define your own StateHandler type until this is fixed up.
Relevant log files
N/A
pact-foundation/pact-jsGitHub
03/02/2023, 6:53 AM