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

Invalid typings of request matchers #1702

Closed
merlinnot opened this issue Sep 4, 2019 · 1 comment · Fixed by #1703
Closed

Invalid typings of request matchers #1702

merlinnot opened this issue Sep 4, 2019 · 1 comment · Fixed by #1703
Labels
released TypeScript Anything related to TypeScript

Comments

@merlinnot
Copy link
Contributor

What is the expected behavior?

I'd expect to be able to provide objects with any JSON-parseable value as request matcher, like so:

nock('https://example.com')
  .post('/path', { number: 1 })
  .reply(200);

What is the actual behavior?

Type definitions allow only strings to be passed as values.

Possible solution

Extend type definitions to include all supported types.

How to reproduce the issue

See the example code above. It will result in the TypeScript compiler error: Argument of type '{ number: number; }' is not assignable to parameter of type 'string | RegExp | Buffer | DataMatcher | ((body: any) => boolean) | undefined'.

Does the bug have a test case?

I guess it's not currently in the codebase.

Versions

Software Version(s)
Nock v11.3.2
Node v10.16.3
@nockbot
Copy link
Collaborator

nockbot commented Sep 5, 2019

🎉 This issue has been resolved in version 11.3.3 🎉

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
released TypeScript Anything related to TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants