Skip to content

Commit 7c34847

Browse files
test(vue-query): add test case for setQueryData type inference in functions
1 parent b5c6dde commit 7c34847

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/vue-query/src/__tests__/queryClient.test-d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ describe('setQueryData', () => {
9696

9797
expectTypeOf(data).toEqualTypeOf<string | undefined>()
9898
})
99+
100+
it('should preserve updater parameter type inference when used in functions with explicit return types', () => {
101+
const queryKey = ['key'] as DataTag<Array<string>, number>
102+
const queryClient = new QueryClient()
103+
104+
// Simulate usage inside a function with explicit return type
105+
// The outer function returns 'unknown' but this shouldn't affect the updater's type inference
106+
;(() =>
107+
queryClient.setQueryData(queryKey, (data) => {
108+
expectTypeOf(data).toEqualTypeOf<number | undefined>()
109+
return data
110+
})) satisfies () => unknown
111+
})
99112
})
100113

101114
describe('fetchInfiniteQuery', () => {

0 commit comments

Comments
 (0)