fix(types): data matcher for body and query.#1725
Conversation
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.
paulmelnikow
left a comment
There was a problem hiding this comment.
This looks great 👍
Do you think it'd be worth including a link to that TS thread with the code?
|
@paulmelnikow I've added that link to the comment. |
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. |
|
🎉 This PR is included in version 11.3.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* 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.
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:
undefinedto scalar values allowed in arrays or as values in objects.This allows for interfaces with optional keys to be passed in. ref fix: authorize undefined values in DataMatcher type #1723
Allows enforcing non-arrays for
.query.RequestBodyMatchernow extends the array and map types instead of the rawDataMatcher.Allowing arrays fixes
DataMatchertype does not allow arrays be used for POST bodies #1724.This also ensures that booleans, numbers, and
nullare not considered valid.