Skip to content

Commit d2a3875

Browse files
committed
fix: try to fix AnyQueryClient typings
1 parent c9af938 commit d2a3875

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.changeset/early-books-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mobx-tanstack-query": patch
3+
---
4+
5+
try to fix AnyQueryClient wrong typings for bun usage

src/mutation.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { type DefaultError, QueryClient } from '@tanstack/query-core';
1+
import {
2+
type DefaultError,
3+
QueryClient as QueryClientCore,
4+
} from '@tanstack/query-core';
25
import { reaction } from 'mobx';
3-
import { describe, expect, it, vi } from 'vitest';
6+
import { describe, expect, expectTypeOf, it, vi } from 'vitest';
47

58
import { Mutation } from './mutation';
69
import type { MutationConfig } from './mutation.types';
@@ -32,7 +35,7 @@ class MutationMock<
3235
});
3336
super({
3437
...options,
35-
queryClient: new QueryClient({}),
38+
queryClient: new QueryClientCore({}),
3639
// @ts-expect-error
3740
mutationFn,
3841
});
@@ -197,4 +200,17 @@ describe('Mutation', () => {
197200

198201
vi.useRealTimers();
199202
});
203+
204+
it('typings query client core test', () => {
205+
const queryClientCore = new QueryClientCore();
206+
207+
const testMutation = new Mutation({
208+
queryClient: queryClientCore,
209+
mutationFn: async () => {},
210+
});
211+
212+
expectTypeOf(testMutation).toEqualTypeOf<
213+
Mutation<void, void, Error, unknown>
214+
>();
215+
});
200216
});

src/query-client.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type IQueryClient = IQueryClientCore;
2525
*/
2626
export type QueryClientInterface = IQueryClientCore;
2727

28-
export type AnyQueryClient = QueryClient | IQueryClientCore;
28+
export type AnyQueryClient = QueryClient | IQueryClientCore | QueryClientCore;
2929

3030
export interface DefaultOptions<TError = DefaultError>
3131
extends Omit<DefaultCoreOptions<TError>, 'queries' | 'mutations'> {

0 commit comments

Comments
 (0)