test: add callback return type tests for mutation callbacks (#9252)
* Revert "refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)" This reverts commit 982f6ca6073c68a152621772e3cd42c02150917f. * test: add callback return type tests for mutation callbacks Adds test coverage for mutation callback return types, inspired by the discussions and [TkDodo's comment](https://github.com/TanStack/query/pull/9245#issuecomment-2939664588 ) in #9245 and the original Promise.all() edge case identified in #9202. The original PR #9202 narrowed callback return types from `Promise<unknown> | unknown` to `Promise<void> | void`, but this broke common patterns like: ```ts onSuccess: (data) => Promise.all([ invalidateQueries(), trackAnalytics(), ]) ``` As noted in [the original discussion](https://github.com/TanStack/query/pull/9202#issuecomment-2934491122), this `Promise.all()` pattern was a legitimate use case that many users relied on. These tests ensure we support all the callback patterns that users expect: ✅ **Sync patterns**: Implicit void, explicit void, non-void returns ✅ **Async patterns**: Async functions, Promise.resolve(), Promise<T> returns ✅ **Promise.all() patterns**: The original breaking case from #9202 ✅ **Promise.allSettled() patterns**: Additional parallel operation support ✅ **Mixed patterns**: Different callback types in same mutation ✅ **Error handling**: All patterns work in error scenarios ✅ **Return value isolation**: Callback returns don't affect mutation result * refactor(tests): remove unnecessary parameters in mutation tests * test(mutations): fix mutation test ordering with error handling and cleanup verification --------- Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
B
Braden Wong committed
2b9b122b98e9eae16c8c29fd6fb720814d503526
Parent: 4335993
Committed by GitHub <noreply@github.com>
on 6/5/2025, 3:20:23 PM