@tanstack/solid-query
Advanced tools
Comparing version 5.0.0-alpha.20 to 5.0.0-alpha.21
@@ -120,6 +120,2 @@ import { fireEvent, render, screen, waitFor } from 'solid-testing-library'; | ||
}, | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
placeholderData: 'string', | ||
@@ -137,10 +133,2 @@ // @ts-expect-error (initialData: string) | ||
}, | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
onError: (e) => { | ||
expectType(e); | ||
expectTypeNotAny(e); | ||
}, | ||
placeholderData: 'string', | ||
@@ -258,6 +246,2 @@ // @ts-expect-error (initialData: string) | ||
}, | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
placeholderData: 'string', | ||
@@ -275,10 +259,2 @@ // @ts-expect-error (initialData: string) | ||
}, | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
onError: (e) => { | ||
expectType(e); | ||
expectTypeNotAny(e); | ||
}, | ||
placeholderData: 'string', | ||
@@ -370,3 +346,3 @@ // @ts-expect-error (initialData: string) | ||
})); | ||
// select / onSuccess / onSettled params are "indirectly" enforced | ||
// select params are "indirectly" enforced | ||
createQueries(() => ({ | ||
@@ -378,6 +354,2 @@ queries: [ | ||
queryFn: () => 'string', | ||
// @ts-expect-error (noImplicitAny) | ||
onSuccess: (a) => null, | ||
// @ts-expect-error (noImplicitAny) | ||
onSettled: (a) => null, | ||
}, | ||
@@ -388,10 +360,2 @@ // however you can add a type to the callback | ||
queryFn: () => 'string', | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
onSettled: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
}, | ||
@@ -402,4 +366,2 @@ // the type you do pass is enforced | ||
queryFn: () => 'string', | ||
// @ts-expect-error (only accepts string) | ||
onSuccess: (a) => null, | ||
}, | ||
@@ -410,8 +372,2 @@ { | ||
select: (a) => parseInt(a), | ||
// @ts-expect-error (select is defined => only accepts number) | ||
onSuccess: (a) => null, | ||
onSettled: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
}, | ||
@@ -422,3 +378,2 @@ ], | ||
createQueries(() => ({ | ||
// @ts-expect-error (onSuccess only accepts string) | ||
queries: Array(50).map((_, i) => ({ | ||
@@ -428,3 +383,2 @@ queryKey: ['key', i], | ||
select: (data) => data.toString(), | ||
onSuccess: (_data) => null, | ||
})), | ||
@@ -437,3 +391,2 @@ })); | ||
select: (data) => data.toString(), | ||
onSuccess: (_data) => null, | ||
})), | ||
@@ -447,6 +400,2 @@ })); | ||
queryFn: () => 'string', | ||
// @ts-expect-error (noImplicitAny) | ||
onSuccess: (a) => null, | ||
// @ts-expect-error (noImplicitAny) | ||
onSettled: (a) => null, | ||
}, | ||
@@ -456,10 +405,2 @@ { | ||
queryFn: () => 'string', | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
onSettled: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
}, | ||
@@ -470,7 +411,2 @@ { | ||
select: (a) => parseInt(a), | ||
onSuccess: (_a) => null, | ||
onSettled: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
}, | ||
@@ -488,8 +424,2 @@ ], | ||
queryFn: () => Promise.resolve('string'), | ||
onSuccess: (a) => { | ||
expectType(a); | ||
expectTypeNotAny(a); | ||
}, | ||
// @ts-expect-error (refuses to accept a Promise) | ||
onSettled: (a) => null, | ||
}, | ||
@@ -574,7 +504,6 @@ ], | ||
(query) => { | ||
const { queryFn: fn, queryKey: key, onError: err } = query; | ||
const { queryFn: fn, queryKey: key } = query; | ||
expectType(fn); | ||
return { | ||
queryKey: key, | ||
onError: err, | ||
queryFn: fn | ||
@@ -581,0 +510,0 @@ ? (ctx) => { |
@@ -143,64 +143,2 @@ import { fireEvent, render, screen, waitFor } from 'solid-testing-library'; | ||
}); | ||
it('should call onSuccess on the first successful call', async () => { | ||
const key = queryKey(); | ||
const successFn = vi.fn(); | ||
function Page() { | ||
createQuery(() => ({ | ||
queryKey: [key], | ||
queryFn: async () => { | ||
await sleep(10); | ||
return key; | ||
}, | ||
suspense: true, | ||
select: () => 'selected', | ||
onSuccess: successFn, | ||
})); | ||
return <>rendered</>; | ||
} | ||
render(() => (<QueryClientProvider client={queryClient}> | ||
<Suspense fallback="loading"> | ||
<Page /> | ||
</Suspense> | ||
</QueryClientProvider>)); | ||
await waitFor(() => screen.getByText('rendered')); | ||
await waitFor(() => expect(successFn).toHaveBeenCalledTimes(1)); | ||
await waitFor(() => expect(successFn).toHaveBeenCalledWith('selected')); | ||
}); | ||
it('should call every onSuccess handler within a suspense boundary', async () => { | ||
const key = queryKey(); | ||
const successFn1 = vi.fn(); | ||
const successFn2 = vi.fn(); | ||
function FirstComponent() { | ||
createQuery(() => ({ | ||
queryKey: key, | ||
queryFn: () => { | ||
sleep(10); | ||
return 'data'; | ||
}, | ||
onSuccess: successFn1, | ||
})); | ||
return <span>first</span>; | ||
} | ||
function SecondComponent() { | ||
createQuery(() => ({ | ||
queryKey: key, | ||
queryFn: () => { | ||
sleep(10); | ||
return 'data'; | ||
}, | ||
onSuccess: successFn2, | ||
})); | ||
return <span>second</span>; | ||
} | ||
render(() => (<QueryClientProvider client={queryClient}> | ||
<Suspense fallback="loading"> | ||
<FirstComponent /> | ||
<SecondComponent /> | ||
</Suspense> | ||
, | ||
</QueryClientProvider>)); | ||
await waitFor(() => screen.getByText('second')); | ||
await waitFor(() => expect(successFn1).toHaveBeenCalledTimes(1)); | ||
await waitFor(() => expect(successFn2).toHaveBeenCalledTimes(1)); | ||
}); | ||
// https://github.com/tannerlinsley/react-query/issues/468 | ||
@@ -207,0 +145,0 @@ it('should reset error state if new component instances are mounted', async () => { |
{ | ||
"name": "@tanstack/solid-query", | ||
"version": "5.0.0-alpha.20", | ||
"version": "5.0.0-alpha.21", | ||
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid", | ||
@@ -46,3 +46,3 @@ "author": "tannerlinsley", | ||
"dependencies": { | ||
"@tanstack/query-core": "5.0.0-alpha.19" | ||
"@tanstack/query-core": "5.0.0-alpha.21" | ||
}, | ||
@@ -49,0 +49,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
820928
20525
+ Added@tanstack/query-core@5.0.0-alpha.21(transitive)
- Removed@tanstack/query-core@5.0.0-alpha.19(transitive)