Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 of 5 tasks
ghost91- opened this issue Jan 16, 2024 · 0 comments
Open
4 of 5 tasks
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@ghost91-
Copy link

Software versions

Please provide at least OS and version of pact-js

  • OS: Arch Linux, Ubuntu, Windows (it's irrelevant)
  • Consumer Pact library: Pact JS v12.1.2
  • Provider Pact library: Pact JS v12.1.2
  • Node Version: v20.11.0

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

There are no TypeScript errors when trying to provide a stateHandler with setup and teardown to a Verifier.

Actual behaviour

Trying to provide a stateHandler with setup and teardown results in the following TypeScript error:

error TS2322: 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>'.

Steps to reproduce

import { Verifier } from '@pact-foundation/pact';

const verifier = new Verifier({
  stateHandlers: {
    'name of the stateHandler': { setup: async () => {}, teardown: async () => {} } // this line produces a TypeScript error
  }
});
@ghost91- ghost91- added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant