-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Comparing changes
Open a pull request
base repository: TanStack/query
base: main@{1day}
head repository: TanStack/query
compare: main
- 11 commits
- 112 files changed
- 9 contributors
Commits on Jun 2, 2025
-
refactor(types): narrow onSuccess/onError/onMutate/onSettled callback…
… types to Promise<void> | void (#9202) * refactor: narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void Previously, the `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks were typed as `() => Promise<unknown> | unknown`. While `unknown` is technically valid, it implies that the return value might be used, assigned, or further processed. However, throughout the codebase, these callbacks are invoked solely for their side effects, and their return values are always ignored. Narrowing the type to `Promise<void> | void` makes this intent explicit, clarifies that any return value will be discarded, and prevents misleading type signatures that suggest otherwise. This commit narrows their types to `() => Promise<void> | void`, which more accurately reflects their intended use. * docs: update callback return types to Promise<void> | void in mutation-related documentation This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
Configuration menu - View commit details
-
Copy full SHA for 982f6ca - Browse repository at this point
Copy the full SHA 982f6caView commit details -
docs: Mention query keys needs to be serializable using `JSON.stringi…
…fy` (#9204) This was not clear to me and so maybe a useful addition to the docs
Configuration menu - View commit details
-
Copy full SHA for ff2b51a - Browse repository at this point
Copy the full SHA ff2b51aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7c5a8b6 - Browse repository at this point
Copy the full SHA 7c5a8b6View commit details -
refactor(query-core): extract context creation to functions and move …
…type assertions (#9210) This refactor extracts the creation of the query function context and fetch context into dedicated helper functions (e.g., `createQueryFnContext`), improving code readability. This change: - Moves type assertions and type handling higher up, reducing inline type noise and making type boundaries clearer. - Replaces ad-hoc object construction with a function that does one thing (build query contexts). No functional behavior is changed; this is a structural and type-safety improvement.
Configuration menu - View commit details
-
Copy full SHA for 0cbfc5e - Browse repository at this point
Copy the full SHA 0cbfc5eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e083c6 - Browse repository at this point
Copy the full SHA 0e083c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 214fafd - Browse repository at this point
Copy the full SHA 214fafdView commit details -
feat(query-devtools): add indicator for staleTime: "static" (#9215)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Configuration menu - View commit details
-
Copy full SHA for 3e7d715 - Browse repository at this point
Copy the full SHA 3e7d715View commit details -
chore: improve type safety in
getQueryData
by using generics (#9218)Refactored the `getQueryData` method in `QueryClient` to use generics for type inference instead of type assertion with `as`. The previous implementation of `getQueryData` relied on a type assertion (`as`) to cast the result of `queryCache.get()`: ```typescript return this.#queryCache.get(options.queryHash)?.state.data as | TInferredQueryFnData | undefined ``` While this works, using generics is a more type-safe and idiomatic approach in TypeScript. It allows the type system to infer the correct type for `TInferredQueryFnData` when `queryCache.get` is called, reducing the need for manual type casting and potential runtime errors if the cast is incorrect. ## Changes The `getQueryData` method has been updated to pass `TInferredQueryFnData` as a generic type argument to `this.#queryCache.get()`: **Before:** ```typescript return this.#queryCache.get(options.queryHash)?.state.data as | TInferredQueryFnData | undefined ``` **After:** ```typescript return this.#queryCache.get<TInferredQueryFnData>(options.queryHash)?.state .data ``` This change leverages the existing generic type parameter `TInferredQueryFnData` already defined in the `getQueryData` signature and `QueryCache#get` method.
Configuration menu - View commit details
-
Copy full SHA for 3a89ec9 - Browse repository at this point
Copy the full SHA 3a89ec9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4bf169e - Browse repository at this point
Copy the full SHA 4bf169eView commit details -
chore: remove redundant word in comment (#9231)
Signed-off-by: clonemycode <clonecode@aliyun.com> Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for a2a23a8 - Browse repository at this point
Copy the full SHA a2a23a8View commit details -
refactor(types): remove unnecessary TQueryData generic in InfiniteQue…
…ryObserverOptions (#9224) * refactor(core): remove unnecessary TQueryData in InfiniteQueryObserverOptions * refactor(react-query,solid-query,svelte-query,vue-query,angular-query): remove unnecessary TQueryData in InfiniteQueryObserverOptions * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Configuration menu - View commit details
-
Copy full SHA for efa963d - Browse repository at this point
Copy the full SHA efa963dView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main@{1day}...main