Skip to content

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

Merged
mastermatt merged 2 commits intonock:masterfrom
mastermatt:types/fix-data-matcher
Sep 20, 2019
Merged

fix(types): data matcher for body and query.#1725
mastermatt merged 2 commits intonock:masterfrom
mastermatt:types/fix-data-matcher

Conversation

@mastermatt
Copy link
Copy Markdown
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
Copy Markdown
Member Author

mastermatt commented Sep 19, 2019

@ctotheameron @jgiovaresco @paulmelnikow

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

nockbot commented Sep 20, 2019

🎉 This PR is included in version 11.3.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

juninmd pushed a commit to juninmd/nock that referenced this pull request Mar 21, 2026
* fix(types): data matcher for body and query.

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.
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