@tanstack/preact-query 5.103.2 → 5.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/legacy/HydrationBoundary.d.cts +2 -3
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +2 -3
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +2 -3
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +2 -3
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +4 -5
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +4 -5
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +8 -9
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +8 -9
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.cts +3 -4
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.ts +3 -4
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +7 -8
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +7 -8
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.d.cts +2 -3
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +2 -3
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +9 -9
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +9 -9
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/suspense.cjs.map +1 -1
- package/build/legacy/suspense.d.cts +4 -5
- package/build/legacy/suspense.d.cts.map +1 -1
- package/build/legacy/suspense.d.ts +4 -5
- package/build/legacy/suspense.d.ts.map +1 -1
- package/build/legacy/suspense.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +30 -30
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +30 -30
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -2
- package/build/legacy/useBaseQuery.d.cts.map +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -2
- package/build/legacy/useBaseQuery.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +3 -4
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +3 -4
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -2
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -2
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useMutation.d.cts +1 -2
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +1 -2
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutationState.d.cts +2 -3
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +2 -3
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +1 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +1 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +9 -6
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +9 -6
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +10 -6
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +10 -6
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +11 -8
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +11 -8
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +1 -2
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +1 -2
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/utils.d.cts +2 -3
- package/build/legacy/utils.d.cts.map +1 -1
- package/build/legacy/utils.d.ts +2 -3
- package/build/legacy/utils.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +2 -3
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +2 -3
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +2 -3
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +2 -3
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +4 -5
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +4 -5
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +8 -9
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +8 -9
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.cts +3 -4
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.ts +3 -4
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +7 -8
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +7 -8
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.d.cts +2 -3
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +2 -3
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +9 -9
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +9 -9
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/suspense.cjs.map +1 -1
- package/build/modern/suspense.d.cts +4 -5
- package/build/modern/suspense.d.cts.map +1 -1
- package/build/modern/suspense.d.ts +4 -5
- package/build/modern/suspense.d.ts.map +1 -1
- package/build/modern/suspense.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +30 -30
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +30 -30
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -2
- package/build/modern/useBaseQuery.d.cts.map +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -2
- package/build/modern/useBaseQuery.d.ts.map +1 -1
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +3 -4
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +3 -4
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -2
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +1 -2
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useMutation.d.cts +1 -2
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +1 -2
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutationState.d.cts +2 -3
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +2 -3
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +1 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +1 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +9 -6
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +9 -6
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +10 -6
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +10 -6
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +11 -8
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +11 -8
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +1 -2
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +1 -2
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/utils.d.cts +2 -3
- package/build/modern/utils.d.cts.map +1 -1
- package/build/modern/utils.d.ts +2 -3
- package/build/modern/utils.d.ts.map +1 -1
- package/package.json +9 -10
- package/src/infiniteQueryOptions.ts +1 -1
- package/src/queryOptions.ts +4 -4
- package/src/suspense.ts +1 -2
- package/src/types.ts +5 -4
- package/src/useBaseQuery.ts +3 -6
- package/src/useQueries.ts +6 -2
- package/src/useQuery.ts +7 -2
- package/src/useSuspenseQueries.ts +7 -3
- package/build/query-codemods/eslint.config.js +0 -25
- package/build/query-codemods/package.json +0 -38
- package/build/query-codemods/root.eslint.config.js +0 -113
- package/build/query-codemods/tsconfig.json +0 -8
- package/build/query-codemods/vite.config.ts +0 -30
- /package/build/codemods/{src/utils → utils}/index.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/query-cache-transformer.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/query-client-transformer.cjs +0 -0
- /package/build/codemods/{src/utils → utils}/transformers/use-query-like-transformer.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/key-transformation.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/replace-import-specifier.cjs +0 -0
- /package/build/codemods/{src/v4 → v4}/utils/replacers/key-replacer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/is-loading/is-loading.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/README.md +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/keep-previous-data.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/keep-previous-data/utils/already-has-placeholder-data-property.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/remove-overloads.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/transformers/filter-aware-usage-transformer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/utils/index.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/remove-overloads/utils/unknown-usage-error.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/rename-hydrate/rename-hydrate.cjs +0 -0
- /package/build/codemods/{src/v5 → v5}/rename-properties/rename-properties.cjs +0 -0
|
@@ -92,7 +92,7 @@ export type UnusedSkipTokenInfiniteOptions<
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
|
|
95
|
-
* never `undefined
|
|
95
|
+
* never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
96
96
|
*
|
|
97
97
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
98
98
|
* @template TError - The type of errors your `queryFn` may throw.
|
package/src/queryOptions.ts
CHANGED
|
@@ -71,7 +71,7 @@ export type UnusedSkipTokenOptions<
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
|
|
74
|
-
* `undefined
|
|
74
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
75
75
|
*
|
|
76
76
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
77
77
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
@@ -92,8 +92,7 @@ export type DefinedInitialDataOptions<
|
|
|
92
92
|
* cache.
|
|
93
93
|
*/
|
|
94
94
|
initialData:
|
|
95
|
-
| NonUndefinedGuard<TQueryFnData>
|
|
96
|
-
| (() => NonUndefinedGuard<TQueryFnData>)
|
|
95
|
+
NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>)
|
|
97
96
|
/**
|
|
98
97
|
* Optional here, but omitting it is only safe when no fetch will be attempted — for example with
|
|
99
98
|
* `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no
|
|
@@ -107,7 +106,8 @@ export type DefinedInitialDataOptions<
|
|
|
107
106
|
* be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
|
|
108
107
|
* is the query key to generate options for.
|
|
109
108
|
*
|
|
110
|
-
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined
|
|
109
|
+
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
110
|
+
* a `select` changes `TData` to include `undefined`).
|
|
111
111
|
*
|
|
112
112
|
* @see {@link useQuery} to run a query with these options.
|
|
113
113
|
* @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
|
package/src/suspense.ts
CHANGED
|
@@ -49,8 +49,7 @@ export const ensureSuspenseTimers = (
|
|
|
49
49
|
|
|
50
50
|
export const shouldSuspend = (
|
|
51
51
|
defaultedOptions:
|
|
52
|
-
|
|
53
|
-
| undefined,
|
|
52
|
+
DefaultedQueryObserverOptions<any, any, any, any, any> | undefined,
|
|
54
53
|
result: QueryObserverResult<any, any>,
|
|
55
54
|
) => defaultedOptions?.suspense && result.isPending
|
|
56
55
|
|
package/src/types.ts
CHANGED
|
@@ -343,8 +343,8 @@ export type UseSuspenseQueryResult<
|
|
|
343
343
|
|
|
344
344
|
/**
|
|
345
345
|
* The result of `useQuery` when `initialData` is set, or of `useSuspenseQuery` before the `isPlaceholderData`
|
|
346
|
-
* omission — `data` is never `undefined
|
|
347
|
-
* `@tanstack/query-core`.
|
|
346
|
+
* omission — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
347
|
+
* Re-exports {@link DefinedQueryObserverResult} from `@tanstack/query-core`.
|
|
348
348
|
*
|
|
349
349
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
350
350
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
@@ -367,8 +367,9 @@ export type UseInfiniteQueryResult<
|
|
|
367
367
|
> = InfiniteQueryObserverResult<TData, TError>
|
|
368
368
|
|
|
369
369
|
/**
|
|
370
|
-
* The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined
|
|
371
|
-
* {@link DefinedInfiniteQueryObserverResult}
|
|
370
|
+
* The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined` (unless a
|
|
371
|
+
* `select` changes `TData` to include `undefined`). Re-exports {@link DefinedInfiniteQueryObserverResult}
|
|
372
|
+
* from `@tanstack/query-core`.
|
|
372
373
|
*
|
|
373
374
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
374
375
|
* @template TError - The type of errors your `queryFn` may throw.
|
package/src/useBaseQuery.ts
CHANGED
|
@@ -55,12 +55,9 @@ export function useBaseQuery<
|
|
|
55
55
|
|
|
56
56
|
const query = client
|
|
57
57
|
.getQueryCache()
|
|
58
|
-
.get<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
TQueryData,
|
|
62
|
-
TQueryKey
|
|
63
|
-
>(defaultedOptions.queryHash)
|
|
58
|
+
.get<TQueryFnData, TError, TQueryData, TQueryKey>(
|
|
59
|
+
defaultedOptions.queryHash,
|
|
60
|
+
)
|
|
64
61
|
|
|
65
62
|
if (process.env.NODE_ENV !== 'production') {
|
|
66
63
|
if (!defaultedOptions.queryFn) {
|
package/src/useQueries.ts
CHANGED
|
@@ -143,10 +143,14 @@ type GetUseQueryResult<T> =
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* The `queries` array accepted by `useQueries`. Recursively unwraps each tuple element so every entry's
|
|
146
|
-
* `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements
|
|
147
|
-
* `unknown[]`) is returned as-is; a non-tuple array of a known element type, or a tuple past 20 elements, falls
|
|
146
|
+
* `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements — past that, a tuple falls
|
|
148
147
|
* back to a single homogeneous options type.
|
|
149
148
|
*
|
|
149
|
+
* An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally
|
|
150
|
+
* matches a query options object is mapped per-element instead, still inferring each entry individually; any
|
|
151
|
+
* other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
|
|
152
|
+
* that same homogeneous options type too.
|
|
153
|
+
*
|
|
150
154
|
* @template T - The type of the `queries` array as written at the call site.
|
|
151
155
|
* @template TResults - The internal accumulator that this type builds during recursion. It is not meant
|
|
152
156
|
* to be set explicitly.
|
package/src/useQuery.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type {
|
|
|
13
13
|
import { useBaseQuery } from './useBaseQuery'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined
|
|
16
|
+
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
17
|
+
* a `select` changes `TData` to include `undefined`).
|
|
17
18
|
*
|
|
18
19
|
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
19
20
|
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
|
|
@@ -223,7 +224,9 @@ export function useQuery<
|
|
|
223
224
|
* ```
|
|
224
225
|
*
|
|
225
226
|
* @example
|
|
226
|
-
* Seeding a detail query from an already-cached list, to skip the loading state
|
|
227
|
+
* Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
|
|
228
|
+
* over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
|
|
229
|
+
* fetched rather than from now:
|
|
227
230
|
* ```tsx
|
|
228
231
|
* import { useQuery, useQueryClient } from '@tanstack/preact-query'
|
|
229
232
|
*
|
|
@@ -237,6 +240,8 @@ export function useQuery<
|
|
|
237
240
|
* queryClient
|
|
238
241
|
* .getQueryData<Array<Post>>(['posts'])
|
|
239
242
|
* ?.find((post) => post.id === postId),
|
|
243
|
+
* initialDataUpdatedAt: () =>
|
|
244
|
+
* queryClient.getQueryState(['posts'])?.dataUpdatedAt,
|
|
240
245
|
* })
|
|
241
246
|
*
|
|
242
247
|
* if (isError) return <span>Error: {error.message}</span>
|
|
@@ -106,9 +106,13 @@ type GetUseSuspenseQueryResult<T> =
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every
|
|
109
|
-
* entry's `queryFn`/`select` are inferred individually, up to 20 elements
|
|
110
|
-
*
|
|
111
|
-
*
|
|
109
|
+
* entry's `queryFn`/`select` are inferred individually, up to 20 elements — past that, a tuple falls back to
|
|
110
|
+
* a single homogeneous {@link UseSuspenseQueryOptions} type.
|
|
111
|
+
*
|
|
112
|
+
* An opaque array (e.g. `unknown[]`) is returned as-is; a non-tuple array whose element type structurally
|
|
113
|
+
* matches a query options object is mapped per-element instead, still inferring each entry individually; any
|
|
114
|
+
* other non-tuple array — one whose element type doesn't match the expected options shape — falls back to
|
|
115
|
+
* that same homogeneous options type too.
|
|
112
116
|
*
|
|
113
117
|
* @template T - The type of the `queries` array as written at the call site.
|
|
114
118
|
* @template TResults - The internal accumulator that this type builds during recursion. It is not meant
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import rootConfig from './root.eslint.config.js'
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
...rootConfig,
|
|
7
|
-
{
|
|
8
|
-
rules: {
|
|
9
|
-
'cspell/spellchecker': 'off',
|
|
10
|
-
'@typescript-eslint/no-unnecessary-condition': 'off',
|
|
11
|
-
'import/no-duplicates': 'off',
|
|
12
|
-
'import/no-unresolved': 'off',
|
|
13
|
-
'import/order': 'off',
|
|
14
|
-
'no-shadow': 'off',
|
|
15
|
-
'sort-imports': 'off',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
files: ['src/**/__testfixtures__/**'],
|
|
20
|
-
rules: {
|
|
21
|
-
// Codemod fixtures intentionally preserve historical QueryClient syntax.
|
|
22
|
-
'no-restricted-syntax': 'off',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
]
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tanstack/query-codemods",
|
|
3
|
-
"private": true,
|
|
4
|
-
"description": "Collection of codemods to make the migration easier.",
|
|
5
|
-
"author": "Balázs Máté Petró",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/TanStack/query.git",
|
|
10
|
-
"directory": "packages/query-codemods"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://tanstack.com/query",
|
|
13
|
-
"funding": {
|
|
14
|
-
"type": "github",
|
|
15
|
-
"url": "https://github.com/sponsors/tannerlinsley"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"clean": "premove ./coverage ./dist-ts",
|
|
19
|
-
"test:eslint": "eslint --concurrency=auto ./src",
|
|
20
|
-
"test:lib": "vitest",
|
|
21
|
-
"test:lib:dev": "pnpm run test:lib --watch"
|
|
22
|
-
},
|
|
23
|
-
"type": "module",
|
|
24
|
-
"exports": {
|
|
25
|
-
"./package.json": "./package.json"
|
|
26
|
-
},
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"files": [
|
|
29
|
-
"src",
|
|
30
|
-
"!src/jest.config.js",
|
|
31
|
-
"!src/**/__testfixtures__",
|
|
32
|
-
"!src/**/__tests__"
|
|
33
|
-
],
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@types/jscodeshift": "17.3.0",
|
|
36
|
-
"jscodeshift": "17.3.0"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
// @ts-ignore Needed due to moduleResolution Node vs Bundler
|
|
4
|
-
import { tanstackConfig } from '@tanstack/eslint-config'
|
|
5
|
-
import pluginCspell from '@cspell/eslint-plugin'
|
|
6
|
-
import vitest from '@vitest/eslint-plugin'
|
|
7
|
-
|
|
8
|
-
export default [
|
|
9
|
-
...tanstackConfig,
|
|
10
|
-
{
|
|
11
|
-
name: 'tanstack/temp',
|
|
12
|
-
plugins: {
|
|
13
|
-
cspell: pluginCspell,
|
|
14
|
-
},
|
|
15
|
-
rules: {
|
|
16
|
-
'cspell/spellchecker': [
|
|
17
|
-
'warn',
|
|
18
|
-
{
|
|
19
|
-
cspell: {
|
|
20
|
-
words: [
|
|
21
|
-
'Promisable', // Our public interface
|
|
22
|
-
'TSES', // @typescript-eslint package's interface
|
|
23
|
-
'codemod', // We support our codemod
|
|
24
|
-
'combinate', // Library name
|
|
25
|
-
'datatag', // Query options tagging
|
|
26
|
-
'extralight', // Our public interface
|
|
27
|
-
'jscodeshift',
|
|
28
|
-
'refetches', // Query refetch operations
|
|
29
|
-
'retryer', // Our public interface
|
|
30
|
-
'solidjs', // Our target framework
|
|
31
|
-
'tabular-nums', // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
|
|
32
|
-
'tanstack', // Our package scope
|
|
33
|
-
'todos', // Too general word to be caught as error
|
|
34
|
-
'tsqd', // Our public interface (TanStack Query Devtools shorthand)
|
|
35
|
-
'tsdown', // We use tsdown as builder
|
|
36
|
-
'typecheck', // Field of vite.config.ts
|
|
37
|
-
'vue-demi', // dependency of @tanstack/vue-query
|
|
38
|
-
'ɵkind', // Angular specific
|
|
39
|
-
'ɵproviders', // Angular specific
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
45
|
-
'@typescript-eslint/no-unsafe-function-type': 'off',
|
|
46
|
-
'no-case-declarations': 'off',
|
|
47
|
-
/**
|
|
48
|
-
* Disallows direct calls to deprecated imperative query methods of `QueryClient`
|
|
49
|
-
* for new tests and code
|
|
50
|
-
*
|
|
51
|
-
* Existing tests that directly test the methods from before the refactoring
|
|
52
|
-
* will be grandfathered in and allowed to continue using the deprecated methods.
|
|
53
|
-
* They should not be removed, but new tests should use the new methods instead.
|
|
54
|
-
*/
|
|
55
|
-
'no-restricted-syntax': [
|
|
56
|
-
'error',
|
|
57
|
-
{
|
|
58
|
-
selector:
|
|
59
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="fetchQuery"], [callee.computed=true][callee.property.value="fetchQuery"])',
|
|
60
|
-
message: 'Use queryClient.query(options) instead.',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
selector:
|
|
64
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="prefetchQuery"], [callee.computed=true][callee.property.value="prefetchQuery"])',
|
|
65
|
-
message:
|
|
66
|
-
'Use queryClient.query(options).catch(noop) instead if errors should be swallowed.',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
selector:
|
|
70
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="ensureQueryData"], [callee.computed=true][callee.property.value="ensureQueryData"])',
|
|
71
|
-
message:
|
|
72
|
-
"Use queryClient.query({ ...options, staleTime: 'static' }) instead.",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
selector:
|
|
76
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="fetchInfiniteQuery"], [callee.computed=true][callee.property.value="fetchInfiniteQuery"])',
|
|
77
|
-
message: 'Use queryClient.infiniteQuery(options) instead.',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
selector:
|
|
81
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="prefetchInfiniteQuery"], [callee.computed=true][callee.property.value="prefetchInfiniteQuery"])',
|
|
82
|
-
message:
|
|
83
|
-
'Use queryClient.infiniteQuery(options).catch(noop) instead if errors should be swallowed.',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
selector:
|
|
87
|
-
'CallExpression[callee.type="MemberExpression"]:matches([callee.property.name="ensureInfiniteQueryData"], [callee.computed=true][callee.property.value="ensureInfiniteQueryData"])',
|
|
88
|
-
message:
|
|
89
|
-
"Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead.",
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
'prefer-const': 'off',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'],
|
|
97
|
-
plugins: { vitest },
|
|
98
|
-
rules: {
|
|
99
|
-
...vitest.configs.recommended.rules,
|
|
100
|
-
'vitest/consistent-test-it': [
|
|
101
|
-
'error',
|
|
102
|
-
{ fn: 'it', withinDescribe: 'it' },
|
|
103
|
-
],
|
|
104
|
-
'vitest/no-standalone-expect': [
|
|
105
|
-
'error',
|
|
106
|
-
{
|
|
107
|
-
additionalTestBlockFunctions: ['itIf'],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
settings: { vitest: { typecheck: true } },
|
|
112
|
-
},
|
|
113
|
-
]
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config'
|
|
2
|
-
|
|
3
|
-
import packageJson from './package.json'
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
// fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660
|
|
7
|
-
resolve: {
|
|
8
|
-
conditions: ['@tanstack/custom-condition'],
|
|
9
|
-
},
|
|
10
|
-
environments: {
|
|
11
|
-
ssr: {
|
|
12
|
-
resolve: {
|
|
13
|
-
conditions: ['@tanstack/custom-condition'],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
test: {
|
|
18
|
-
name: packageJson.name,
|
|
19
|
-
dir: './src',
|
|
20
|
-
watch: false,
|
|
21
|
-
globals: true,
|
|
22
|
-
coverage: {
|
|
23
|
-
enabled: !!process.env.CI,
|
|
24
|
-
provider: 'istanbul',
|
|
25
|
-
include: ['src/**/*.{js,ts,cjs,mjs,jsx,tsx}'],
|
|
26
|
-
},
|
|
27
|
-
typecheck: { enabled: true },
|
|
28
|
-
restoreMocks: true,
|
|
29
|
-
},
|
|
30
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|