- Changed documentation generation script from JavaScript to TypeScript.
- Added new TypeScript script for publishing packages with configuration for different branches.
revertState is used as a fallback for fetching failure.
Clearing it once fetching ends successfully improve memory usage, particularly with queries
returning large amount of data.
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
- Updated Node version in .nvmrc from 22.12.0 to 24.2.0.
- Changed the "verify-links" script in package.json to use "node" instead of "pnpm tsx".
- Removed tsx dependency from package.json and pnpm-lock.yaml.
I just added `@normy/vue-query` addon to normy.
Also, I added `@normy/query-core` addon and refactored `@normy/react-query` to use it, so it would be very easy to add more addons, like to angular, solid and so on
* Revert "refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)"
This reverts commit 982f6ca607.
* test: add callback return type tests for mutation callbacks
Adds test coverage for mutation callback return types, inspired by the discussions and [TkDodo's comment](https://github.com/TanStack/query/pull/9245#issuecomment-2939664588
) in #9245 and the original Promise.all() edge case identified in #9202.
The original PR #9202 narrowed callback return types from `Promise<unknown> | unknown`
to `Promise<void> | void`, but this broke common patterns like:
```ts
onSuccess: (data) => Promise.all([
invalidateQueries(),
trackAnalytics(),
])
```
As noted in [the original discussion](https://github.com/TanStack/query/pull/9202#issuecomment-2934491122),
this `Promise.all()` pattern was a legitimate use case that many users relied on.
These tests ensure we support all the callback patterns that users expect:
✅ **Sync patterns**: Implicit void, explicit void, non-void returns
✅ **Async patterns**: Async functions, Promise.resolve(), Promise<T> returns
✅ **Promise.all() patterns**: The original breaking case from #9202✅ **Promise.allSettled() patterns**: Additional parallel operation support
✅ **Mixed patterns**: Different callback types in same mutation
✅ **Error handling**: All patterns work in error scenarios
✅ **Return value isolation**: Callback returns don't affect mutation result
* refactor(tests): remove unnecessary parameters in mutation tests
* test(mutations): fix mutation test ordering with error handling and cleanup verification
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* Add persisterRestoreByKey
* Fix imports
* Add missing return statement
* Fix test
* docs
* Add extra test
* Merge into single restoreQueries function
- Replaced sponsor image paths that pointed to `_build/assets/...` (invalid in GitHub markdown context)
- Updated to use public URLs (`https://tanstack.com/assets/...`) to prevent broken images
Multiple framework-specific packages (`solid-query`, `svelte-query`, and `angular-query-experimental`) were maintaining their own implementations of the `noop` function, creating unnecessary code duplication across the codebase.
```typescript
// Before: Each package had its own noop
// packages/svelte-query/src/utils.ts
export function noop(): void {}
// packages/solid-query/src/utils.ts (missing, causing import errors)
// Local noop definitions scattered across files
```
Consolidated all `noop` usage to import from the canonical implementation in `@tanstack/query-core`, which all framework packages already depend on.
```typescript
// After: Single source of truth
import { noop } from '@tanstack/query-core'
```
- **Removed duplicate `noop` definition** from `packages/svelte-query/src/utils.ts`
- **Updated import statements** in Solid Query and Svelte Query to use `noop` from `@tanstack/query-core`
- **Fixed missing utils file** in Solid Query that was causing import errors
- **Resolved TypeScript compatibility** issues with `noop`'s overloaded return types
- **Persisters were intentionally left unchanged** as they don't import `query-core` and maintain their own lightweight utils
- **Framework packages already depend on `query-core`**, making this consolidation natural and dependency-free
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.
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.