Skip to content

Commit 07a430b

Browse files
committed
Misc changes to useMutation types/docblocks:
- Fix promise result in pseudo-types on docs - Fix wording for 'abort' method docblock
1 parent d7e83f0 commit 07a430b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

query-old/docs/api/created-api/hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type UseMutation<Definition> = () => [UseMutationTrigger<Definition>, UseMutatio
9595

9696
type UseMutationTrigger<Definition> = (
9797
arg: ArgTypeFrom<Definition>
98-
) => Promise<{ data: ResultTypeFrom<Definition> }> & {
98+
) => Promise<{ data: ResultTypeFrom<Definition> } | { error: BaseQueryError | SerializedError }> & {
9999
arg: {
100100
endpointName: string; // The name of the given endpoint for the mutation
101101
originalArgs: ArgTypeFrom<Definition>; // Arguments passed to the mutation

src/query/core/buildInitiate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ export type MutationActionCreatorResult<
121121
* A method to cancel the mutation promise. Note that this is not intended to prevent the mutation
122122
* that was fired off from reaching the server, but only to assist in handling the response.
123123
*
124-
* Calling `abort()` prior to the promise resolving will make it throw with an error like:
124+
* Calling `abort()` prior to the promise resolving will force it to reach the error state with
125+
* the serialized error:
125126
* `{ name: 'AbortError', message: 'Aborted' }`
126127
*
127128
* @example

src/query/tests/buildHooks.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ describe('hooks tests', () => {
829829

830830
// no-op simply for clearer type assertions
831831
res.then((result) => {
832-
// currently passing with a false positive, because error is getting typed as `any`
833832
expectExactType<
834833
| {
835834
error: { status: number; data: unknown } | SerializedError

0 commit comments

Comments
 (0)