Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

fix: fix request body type when optional #48

Merged
merged 3 commits into from
May 11, 2023

Conversation

nickcaballero
Copy link
Contributor

@nickcaballero nickcaballero commented May 10, 2023

Changes

Checklist

  • Tests updated
  • README updated

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

⚠️ No Changeset found

Latest commit: b5f4b26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

src/index.test.ts Outdated Show resolved Hide resolved
src/index.test.ts Outdated Show resolved Hide resolved
Copy link
Owner

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Great tests, thank you! Left a minor comment on making the written tests a bit more clear in purpose and reducing boilerplate (at first glance it’s not clear what these tests are testing because they copy code from other tests). But not blocking. Will merge either way eventually.

@KriszKecskes
Copy link

Hi,
Is there any news about this? I faced the body type issue today. :-(


// expect error on wrong body type
// @ts-expect-error
await client.post('/post/optional', { body: { error: true } })
Copy link
Owner

Choose a reason for hiding this comment

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

🎉 Awesome! These types of inverse tests are very helpful (sometimes even more helpful than the “assert no error” tests.

@drwpow
Copy link
Owner

drwpow commented May 11, 2023

Thanks again! Happy to merge as-is; the lint issue is minor and I can fix after merge.

@drwpow drwpow merged commit 63ebe48 into drwpow:main May 11, 2023
1 of 2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to use body in POST/PATCH requests when another method doesn't have body defined
3 participants