Skip to content

Commit 8662d1e

Browse files
authored
Merge branch 'alpha' into feature/devtools-offline-toggle
2 parents b1c41c9 + 79b6a5d commit 8662d1e

7 files changed

Lines changed: 32 additions & 9 deletions

File tree

packages/react-query-devtools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query-devtools",
3-
"version": "5.0.0-alpha.9",
3+
"version": "5.0.0-alpha.10",
44
"description": "Developer tools to interact with and visualize the TanStack/react-query cache",
55
"author": "tannerlinsley",
66
"license": "MIT",

packages/react-query-persist-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query-persist-client",
3-
"version": "5.0.0-alpha.9",
3+
"version": "5.0.0-alpha.10",
44
"description": "React bindings to work with persisters in TanStack/react-query",
55
"author": "tannerlinsley",
66
"license": "MIT",

packages/react-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query",
3-
"version": "5.0.0-alpha.9",
3+
"version": "5.0.0-alpha.10",
44
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
55
"author": "tannerlinsley",
66
"license": "MIT",

packages/react-query/src/__tests__/useMutationState.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { useIsMutating, useMutationState } from '../useMutationState'
44
import { useMutation } from '../useMutation'
55
import {
66
createQueryClient,
7+
doNotExecute,
78
renderWithClient,
89
setActTimeout,
910
sleep,
1011
} from './utils'
12+
import type { MutationState, MutationStatus } from '@tanstack/query-core'
1113

1214
describe('useIsMutating', () => {
1315
it('should return the number of fetching mutations', async () => {
@@ -172,6 +174,27 @@ describe('useIsMutating', () => {
172174
})
173175

174176
describe('useMutationState', () => {
177+
describe('types', () => {
178+
it('should default to QueryState', () => {
179+
doNotExecute(() => {
180+
const result = useMutationState({
181+
filters: { status: 'pending' },
182+
})
183+
184+
expectTypeOf(result).toEqualTypeOf<Array<MutationState>>()
185+
})
186+
})
187+
it('should infer with select', () => {
188+
doNotExecute(() => {
189+
const result = useMutationState({
190+
filters: { status: 'pending' },
191+
select: (mutation) => mutation.state.status,
192+
})
193+
194+
expectTypeOf(result).toEqualTypeOf<Array<MutationStatus>>()
195+
})
196+
})
197+
})
175198
it('should return variables after calling mutate', async () => {
176199
const queryClient = createQueryClient()
177200
const variables: unknown[][] = []

packages/react-query/src/useMutationState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import type {
77
Mutation,
88
MutationCache,
99
DefaultError,
10+
MutationState,
1011
} from '@tanstack/query-core'
1112
import { notifyManager, replaceEqualDeep } from '@tanstack/query-core'
1213
import { useQueryClient } from './QueryClientProvider'
13-
import type { MutationState } from '@tanstack/query-core/build/lib/mutation'
1414

1515
export function useIsMutating(
1616
filters?: MutationFilters,
@@ -23,7 +23,7 @@ export function useIsMutating(
2323
).length
2424
}
2525

26-
type MutationStateOptions<TResult> = {
26+
type MutationStateOptions<TResult = MutationState> = {
2727
filters?: MutationFilters
2828
select?: (
2929
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
@@ -46,7 +46,7 @@ function getResult<TResult = MutationState>(
4646
)
4747
}
4848

49-
export function useMutationState<TResult = unknown>(
49+
export function useMutationState<TResult = MutationState>(
5050
options: MutationStateOptions<TResult> = {},
5151
queryClient?: QueryClient,
5252
): Array<TResult> {

packages/vue-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/vue-query",
3-
"version": "5.0.0-alpha.8",
3+
"version": "5.0.0-alpha.10",
44
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
55
"author": "Damian Osipiuk",
66
"license": "MIT",

packages/vue-query/src/useMutationState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useIsMutating(
3131
return length
3232
}
3333

34-
export type MutationStateOptions<TResult> = {
34+
export type MutationStateOptions<TResult = MutationState> = {
3535
filters?: MutationFilters
3636
select?: (
3737
mutation: Mutation<unknown, DefaultError, unknown, unknown>,
@@ -54,7 +54,7 @@ function getResult<TResult = MutationState>(
5454
)
5555
}
5656

57-
export function useMutationState<TResult = unknown>(
57+
export function useMutationState<TResult = MutationState>(
5858
options: MutationStateOptions<TResult> = {},
5959
queryClient?: QueryClient,
6060
): DeepReadonly<Ref<Array<TResult>>> {

0 commit comments

Comments
 (0)