Skip to content

refactor(examples/nextjs-suspense-streaming): drop unnecessary 'as string' cast - #10859

Merged
sukvvon merged 1 commit into
mainfrom
refactor/examples-nextjs-suspense-streaming-drop-unnecessary-as-string
Jun 2, 2026
Merged

refactor(examples/nextjs-suspense-streaming): drop unnecessary 'as string' cast#10859
sukvvon merged 1 commit into
mainfrom
refactor/examples-nextjs-suspense-streaming-drop-unnecessary-as-string

Conversation

@sukvvon

@sukvvonsukvvon commented Jun 2, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Drop the unnecessary as string cast on query.data in useWaitQuery. The queryFn is already annotated with const res: string = ..., so TypeScript infers query.data as string and the cast is redundant — @typescript-eslint/no-unnecessary-type-assertion flags it as well.

- return [query.data as string, query] as const+ return [query.data, query] as const

Found while updating this file in #10858 (isServerenvironmentManager.isServer() migration).

✅ 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

  • Refactor
    • Enhanced type handling in query management to improve code reliability and alignment with framework conventions.

@coderabbitai

coderabbitaiBot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd26474d-4a98-4a61-8c3f-b93698e29fd6

📥 Commits

Reviewing files that changed from the base of the PR and between 1348095 and 95810d4.

📒 Files selected for processing (1)
  • examples/react/nextjs-suspense-streaming/src/app/page.tsx

📝 Walkthrough

Walkthrough

The useWaitQuery hook in the Next.js suspense streaming example no longer explicitly casts query.data to string in its return tuple. The tuple now returns [query.data, query] directly, allowing React Query's type system to infer the data type rather than forcing it through a manual type assertion.

Changes

Type Inference Update

Layer / File(s)Summary
useWaitQuery return type cast removal
examples/react/nextjs-suspense-streaming/src/app/page.tsx
useWaitQuery returns [query.data, query] without the as string cast, relying on React Query's inferred data type instead of explicit type coercion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A tiny type cast melts away,
React Query's inference saves the day,
One line adjusted, clean and bright,
The hook now infers what's right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring 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 (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the main change: removing an unnecessary 'as string' type cast in the examples/nextjs-suspense-streaming file.
Description check✅ PassedThe description follows the required template structure with all major sections completed: Changes section with clear explanation and code diff, fully checked Checklist items, and Release Impact section properly marked.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/examples-nextjs-suspense-streaming-drop-unnecessary-as-string

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

@nx-cloud

nx-cloudBot commented Jun 2, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 95810d4

CommandStatusDurationResult
nx run-many --target=build --exclude=examples/*...✅ Succeeded<1sView ↗
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 40sView ↗

☁️ Nx Cloud last updated this comment at 2026-06-02 02:18:36 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 22 bumped as dependents.

🟩 Patch bumps

PackageVersionReason
@tanstack/lit-query0.2.6 → 0.2.7Changeset
@tanstack/query-devtools5.100.14 → 5.100.15Changeset
@tanstack/vue-query5.100.14 → 5.100.15Changeset
@tanstack/angular-query-experimental5.100.14 → 5.100.15Dependent
@tanstack/angular-query-persist-client5.100.14 → 5.100.15Dependent
@tanstack/eslint-plugin-query5.100.14 → 5.100.15Dependent
@tanstack/preact-query5.100.14 → 5.100.15Dependent
@tanstack/preact-query-devtools5.100.14 → 5.100.15Dependent
@tanstack/preact-query-persist-client5.100.14 → 5.100.15Dependent
@tanstack/query-async-storage-persister5.100.14 → 5.100.15Dependent
@tanstack/query-broadcast-client-experimental5.100.14 → 5.100.15Dependent
@tanstack/query-core5.100.14 → 5.100.15Dependent
@tanstack/query-persist-client-core5.100.14 → 5.100.15Dependent
@tanstack/query-sync-storage-persister5.100.14 → 5.100.15Dependent
@tanstack/react-query5.100.14 → 5.100.15Dependent
@tanstack/react-query-devtools5.100.14 → 5.100.15Dependent
@tanstack/react-query-next-experimental5.100.14 → 5.100.15Dependent
@tanstack/react-query-persist-client5.100.14 → 5.100.15Dependent
@tanstack/solid-query5.100.14 → 5.100.15Dependent
@tanstack/solid-query-devtools5.100.14 → 5.100.15Dependent
@tanstack/solid-query-persist-client5.100.14 → 5.100.15Dependent
@tanstack/svelte-query6.1.33 → 6.1.34Dependent
@tanstack/svelte-query-devtools6.1.33 → 6.1.34Dependent
@tanstack/svelte-query-persist-client6.1.33 → 6.1.34Dependent
@tanstack/vue-query-devtools6.1.33 → 6.1.34Dependent

@pkg-pr-new

pkg-pr-newBot commented Jun 2, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10859

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10859

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10859

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 95810d4

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full12.11 KB (0%)
react minimal9.08 KB (0%)

@sukvvonsukvvon self-assigned this Jun 2, 2026
@sukvvon
sukvvon merged commit f167fa8 into mainJun 2, 2026
9 checks passed
@sukvvon
sukvvon deleted the refactor/examples-nextjs-suspense-streaming-drop-unnecessary-as-string branch June 2, 2026 02:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@sukvvon