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

fix(types): data matcher for body and query. #1725

Merged
merged 2 commits into from Sep 20, 2019

Conversation

mastermatt
Copy link
Member

Fixes: #1724
Closes: #1723

Updates the JSONish type using inspiration from the thread on adding a
JSON type to TS. microsoft/TypeScript#1897 (comment)

This change does a couple sublet things:

Fixes: nock#1724
Closes: nock#1723

Updates the JSONish type using inspiration from the thread on adding a
JSON type to TS. microsoft/TypeScript#1897 (comment)

This change does a couple sublet things:
- Adds `undefined` to scalar values allowed in arrays or as values in objects.
  This allows for interfaces with optional keys to be passed in. ref nock#1723
- Splits out top-level array and objects into their interfaces so they could be used directly.
  Allows enforcing non-arrays for `.query`.
- `RequestBodyMatcher` now extends the array and map types instead of the raw `DataMatcher`.
  Allowing arrays fixes nock#1724.
  This also ensures that booleans, numbers, and `null` are not considered valid.
@mastermatt mastermatt added bug TypeScript Anything related to TypeScript labels Sep 19, 2019
@mastermatt
Copy link
Member Author

mastermatt commented Sep 19, 2019

@ctotheameron @jgiovaresco @paulmelnikow

Copy link
Member

@paulmelnikow paulmelnikow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great 👍

Do you think it'd be worth including a link to that TS thread with the code?

@mastermatt
Copy link
Member Author

@paulmelnikow I've added that link to the comment.
When I merge this, it will publish a new patch and I know you have a few things on master since the last publish. Are you ready for those to go out?

@paulmelnikow
Copy link
Member

When I merge this, it will publish a new patch and I know you have a few things on master since the last publish. Are you ready for those to go out?

Always 😉

Glad to get those refactors out in the world; having them released will actually help validate them. I've started trying to solve #1720 which is the riskier set of changes.

@mastermatt mastermatt merged commit 59b345c into nock:master Sep 20, 2019
@mastermatt mastermatt deleted the types/fix-data-matcher branch September 20, 2019 15:32
@nockbot
Copy link
Collaborator

nockbot commented Sep 20, 2019

🎉 This PR is included in version 11.3.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug released TypeScript Anything related to TypeScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataMatcher type does not allow arrays be used for POST bodies
3 participants