pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.59k stars 343 forks source link

chore: Improve types #1061

Closed TimothyJones closed 1 year ago

TimothyJones commented 1 year ago

PR Template

This fixes #1054 by widening the type so that the V3 matchers no longer need to be called with something that can be assigned to AnyTemplate. Since this is a widening of the type, it is not a breaking change.

I also removed all references to AnyTemplate and added tsdoc so that it is deprecated. It's still exported, but just not used anywhere. It can be removed in a future major release.

While I was there, I refactored the types out of matchers.ts into types.ts for readability. These are now re-exported by matchers.ts so that any (inappropriate) deep links will still work, and anyone importing the type from MatchersV3.Matcher will still work.

I also added a TODO comment that in some future release we'll need to rename the interfaces that have the same names in the V2 and V3 matchers. This affects maintainers, as the current situation will result in confusing types, but I don't think it affects users.

Please don't squash merge this, as the commit messages contain the details for the release notes.

TimothyJones commented 1 year ago

The build is failing because of unrelated reasons. The examples need to be updated (looks like mocha-pact needs updating too).

mefellows commented 1 year ago

Hmm this is a new failure, I've not seen this one before but it seems like it exists in master so entropy has done its thing https://github.com/pact-foundation/pact-js/actions/runs/4190675102/jobs/7264320560#step:4:1477

I'm going to merge and sort out the other build after, and any issues with the types if they are discovered.

Thank you, this is much appreciated!

TimothyJones commented 1 year ago

That failure is because mocha-pact’s peer dependency is set to 9.x, so later versions of npm are pulling in the older one (and should also be failing on npm install- I guess npm ci doesn’t fail like install does, or something).

npm is getting better at peer dependencies, so we need to be more careful about them being correct