Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Mar 13, 2024
1 parent f2ca914 commit 90aa502
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion docs/reference/QueryClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ const data = await queryClient.ensureQueryData({ queryKey, queryFn })
- Defaults to `false`
- If set to `true`, stale data will be refetched in the background, but cached data will be returned immediately.


**Returns**

- `Promise<TData>`
Expand Down
19 changes: 14 additions & 5 deletions packages/query-core/src/tests/queryClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,25 @@ describe('queryClient', () => {
const key = queryKey()
queryClient.setQueryData([key, 'id'], 'old')

const queryFn = () => new Promise((resolve) => {
setTimeout(() => resolve('new'), TIMEOUT)
})
const queryFn = () =>
new Promise((resolve) => {
setTimeout(() => resolve('new'), TIMEOUT)
})

await expect(
queryClient.ensureQueryData({ queryKey: [key, 'id'], queryFn, revalidateIfStale: true }),
queryClient.ensureQueryData({
queryKey: [key, 'id'],
queryFn,
revalidateIfStale: true,
}),
).resolves.toEqual('old')
await sleep(TIMEOUT + 10)
await expect(
queryClient.ensureQueryData({ queryKey: [key, 'id'], queryFn, revalidateIfStale: true }),
queryClient.ensureQueryData({
queryKey: [key, 'id'],
queryFn,
revalidateIfStale: true,
}),
).resolves.toEqual('new')
})
})
Expand Down
3 changes: 1 addition & 2 deletions packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export interface EnsureQueryDataOptions<
TData = TQueryFnData,
TQueryKey extends QueryKey = QueryKey,
TPageParam = never,
> extends FetchQueryOptions<
> extends FetchQueryOptions<
TQueryFnData,
TError,
TData,
Expand All @@ -423,7 +423,6 @@ export interface EnsureQueryDataOptions<
revalidateIfStale?: boolean
}


type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =
| { pages?: never }
| {
Expand Down

0 comments on commit 90aa502

Please sign in to comment.