-
-
Notifications
You must be signed in to change notification settings - Fork 353
chore: Improve types #1061
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
chore: Improve types #1061
Conversation
…as the side effect that functions, Dates and other inappropriate types can now be passed to matchers, and the benefit that people using interfaces don't get spurious errors. Fixes pact-foundation#1054
The build is failing because of unrelated reasons. The examples need to be updated (looks like mocha-pact needs updating too). |
} | ||
|
||
if (Object.prototype.toString.call(input) === '[object Array]') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what on earth was going on here in the first place 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old school JS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Array.isArray is “reasonably” new
Hmm this is a new failure, I've not seen this one before but it seems like it exists in 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! |
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 |
npm run dist
works locally (this will run tests, lint and build)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 bymatchers.ts
so that any (inappropriate) deep links will still work, and anyone importing the type fromMatchersV3.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.