Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
syncedQueryanduseObservableSyncedQueryreject valid queries whenselectreturns a different type fromqueryFn. This affects both TanStack'squeryOptions()helper and inferred plain-object options.For example, this should produce an observable number:
Before, TypeScript rejects the
Todo[] => numberselection because the integration expectsTodo[] => Todo[]. After, the same call compiles and the observable getter infersnumber, without explicit Legend generics or casts.Type correction
TanStack separates the raw query data from the selected observer result.
ObservableQueryOptionsincorrectly used selectedTDatain the raw-data slot. Internal observer declarations also supplied four generic arguments, placingTQueryKeyin that slot.All internal observer types now use the same five-argument ordering:
The emitted runtime JavaScript is unchanged.
Why replace the mock?
The deleted test,
get returns refetched data after the initial run, mocked the entire@tanstack/query-coremodule. Its observer returned fixed"initial"and"fresh"strings and had a no-op subscription. That usefully checked the private get callback's return value, but could not demonstrate real selection or cache propagation.The replacement uses a real QueryClient and observes the public
observable/syncStateAPIs. Its query function returns local fixtures; no network calls are made."initial"2"fresh"sync(), wait for completion; observable becomes13An active subscription keeps the observable eligible for refetch. The test waits for public
isGettingcompletion and usesfinallyto unsubscribe and clear the client even if an assertion fails.The refetch regression remains covered: in a local mutation check, making refetch discard its returned data caused both the deleted test and its replacement to fail. The replacement checks the observable result rather than directly inspecting
symbolLinked.get.Regression coverage and validation
queryOptions()through both core and React APIs, plain-object inference, raw callback data, and reactive tuple keys.This PR does not address the separate tagged-key inference issue with
anyresults or existinginitialDataselection behavior.