openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

fix(openapi-react-query): mutation results type

Open sacha-c opened this issue 3 months ago • 3 comments

Changes

Adds proper types to the useMutation's onMutateResults fields which are used in onSettled, onError & return object of this hook.

The open issue regarding this bug: https://github.com/openapi-ts/openapi-typescript/issues/2518

I ended up digging further & this seems to fix it, but looking forward for a second pair of eyes to check that my fix is correct 🙂

Here I moved the Options type definition from the generic parameters to the actual options parameter themselves, thus not setting the UseMutationOptions's TOnMutateResult to the default unknown.

How to Review

Checklist

  • [x] Unit tests updated
  • [ ] docs/ updated (if necessary)
  • [ ] pnpm run update:examples run (only applicable for openapi-typescript)

sacha-c avatar Nov 04 '25 20:11 sacha-c

Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
Latest commit ded751e078e3f1a71c4908cdc055f384ebd7ea62

netlify[bot] avatar Nov 04 '25 20:11 netlify[bot]

⚠️ No Changeset found

Latest commit: ded751e078e3f1a71c4908cdc055f384ebd7ea62

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

changeset-bot[bot] avatar Nov 04 '25 20:11 changeset-bot[bot]

Tests fail due to a refactor in Redocly's test folder structure (unrelated to this PR's change), I've opened a separate PR to address that here https://github.com/openapi-ts/openapi-typescript/pull/2522

sacha-c avatar Nov 08 '25 21:11 sacha-c