Skip to content

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented Jan 11, 2026

🎯 Changes

While testing my changes to the @typescript-eslint/no-unnecessary-type-assertion lint rule on this repo, I found these unnecessary type assertions that can be removed without impacting runtime behaviour or triggering TS errors.

typescript-eslint/typescript-eslint#11789

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Chores
    • Internal code quality improvements: removed redundant type annotations and simplified type usages across core query and devtools.
    • Minor comment typo correction and small TypeScript niceties. No user-facing behavior or public API changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 11, 2026

⚠️ No Changeset found

Latest commit: 68fcddc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

📝 Walkthrough

Walkthrough

Removes several explicit type casts and related imports across query-core and query-devtools, plus a minor comment typo fix; no public API or behavioral changes.

Changes

Cohort / File(s) Summary
Query core: comment & default state
packages/query-core/src/query.ts
Fixed a comment typo ("retyer" → "retryer"). In getDefaultState, initialDataUpdatedAt is invoked without an explicit type cast.
Query core: observer type-cleanup
packages/query-core/src/queryObserver.ts
Removed QueryOptions type cast from the fetch call and removed as any cast on select error assignment. Dropped the QueryOptions import.
Devtools: state type removal
packages/query-devtools/src/Devtools.tsx
Removed QueryState import and two QueryState<unknown, Error> casts in query details/state handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • arnoud-dv
  • TkDodo

Poem

🐇 I nibbled casts and cleaned a line,
Hopped through imports, bright and fine,
Typo gone, the rabbits cheer,
Code a tad neater, light and clear.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing unnecessary type assertions from the codebase, which aligns with the actual modifications across multiple files.
Description check ✅ Passed The description follows the template with all required sections completed, including clear motivation, a completed checklist, and proper release impact designation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9149a64 and 26a097f.

📒 Files selected for processing (1)
  • packages/query-core/src/queryObserver.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/query-core/src/queryObserver.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/query-core/src/queryObserver.ts (1)

546-551: Use a null-check for #selectError (don’t rely on truthiness).
Since TError is generic, a falsy thrown value (e.g. '' / 0) would currently skip the error path.

Proposed fix
-    if (this.#selectError) {
-      error = this.#selectError
+    if (this.#selectError !== null) {
+      error = this.#selectError
       data = this.#selectResult
       errorUpdatedAt = Date.now()
       status = 'error'
     }
🧹 Nitpick comments (2)
packages/query-devtools/src/Devtools.tsx (2)

1958-1966: LGTM removing the QueryState<unknown, Error> cast in setState.
One thing to keep an eye on: fetchMeta is being used as an escape hatch for __previousQueryOptions via as any; if you want to tighten this later, a dedicated side-channel (e.g., WeakMap<Query, QueryOptions>) avoids mutating fetchMeta’s shape.


2183-2202: LGTM removing the QueryState<unknown, Error> cast in the loading-path setState.
Same note as above: fetchMeta: { … } as any is still an intentional escape hatch; consider a side-channel if you ever want to remove the remaining any.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44c3cb9 and 9149a64.

📒 Files selected for processing (3)
  • packages/query-core/src/query.ts
  • packages/query-core/src/queryObserver.ts
  • packages/query-devtools/src/Devtools.tsx
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.
Learnt from: sukvvon
Repo: TanStack/query PR: 9892
File: packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx:331-335
Timestamp: 2025-11-22T09:06:05.219Z
Learning: In TanStack/query test files, when a queryFn contains side effects (e.g., setting flags for test verification), prefer async/await syntax for clarity; when there are no side effects, prefer the .then() pattern for conciseness.
📚 Learning: 2025-08-19T03:18:18.303Z
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.

Applied to files:

  • packages/query-core/src/query.ts
  • packages/query-core/src/queryObserver.ts
  • packages/query-devtools/src/Devtools.tsx
📚 Learning: 2025-11-02T22:52:33.071Z
Learnt from: DogPawHat
Repo: TanStack/query PR: 9835
File: packages/query-core/src/__tests__/queryClient.test-d.tsx:242-256
Timestamp: 2025-11-02T22:52:33.071Z
Learning: In the TanStack Query codebase, the new `query` and `infiniteQuery` methods support the `select` option for data transformation, while the legacy `fetchQuery` and `fetchInfiniteQuery` methods do not support `select` and should reject it at the type level.

Applied to files:

  • packages/query-core/src/queryObserver.ts
  • packages/query-devtools/src/Devtools.tsx
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • packages/query-devtools/src/Devtools.tsx
🔇 Additional comments (3)
packages/query-core/src/query.ts (2)

390-406: Comment typo fix is fine (retryer).
No behavior change; the guard still reads correctly.


736-740: Good removal of the unnecessary cast around initialDataUpdatedAt() call.
Keeps intent clear and should still type-narrow correctly via the typeof === 'function' check.

packages/query-core/src/queryObserver.ts (1)

335-346: Passing this.options into Query.fetch directly looks correct.
Assuming QueryObserverOptions structurally contains QueryOptions (it should), this keeps types simpler without changing runtime behavior.

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nice, thank you

@nx-cloud
Copy link

nx-cloud bot commented Jan 16, 2026

View your CI Pipeline Execution ↗ for commit 68fcddc

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 38s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-16 11:49:33 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10028

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10028

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10028

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10028

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10028

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10028

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10028

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10028

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10028

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10028

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10028

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10028

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10028

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10028

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10028

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10028

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10028

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10028

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10028

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10028

commit: 68fcddc

@sentry
Copy link

sentry bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.62%. Comparing base (64d5d62) to head (68fcddc).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #10028       +/-   ##
===========================================
+ Coverage   45.83%   59.62%   +13.78%     
===========================================
  Files         200      129       -71     
  Lines        8524     5738     -2786     
  Branches     1978     1574      -404     
===========================================
- Hits         3907     3421      -486     
+ Misses       4157     2000     -2157     
+ Partials      460      317      -143     
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (ø)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister 43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental 24.39% <ø> (ø)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core 97.37% <100.00%> (ø)
@tanstack/query-devtools 3.38% <ø> (ø)
@tanstack/query-persist-client-core 80.00% <ø> (ø)
@tanstack/query-sync-storage-persister 84.61% <ø> (ø)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query 96.73% <ø> (ø)
@tanstack/react-query-devtools 9.25% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 77.81% <ø> (ø)
@tanstack/solid-query-devtools 64.17% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query 71.91% <ø> (ø)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TkDodo TkDodo merged commit 0d07172 into TanStack:main Jan 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants