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
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 2, 2026

🎯 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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

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 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing an unnecessary 'as string' type cast in the examples/nextjs-suspense-streaming file.
Description check ✅ Passed The 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 ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check 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
Copy link
Copy Markdown

nx-cloud Bot commented Jun 2, 2026

View your CI Pipeline Execution ↗ for commit 95810d4

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.6 → 0.2.7 Changeset
@tanstack/query-devtools 5.100.14 → 5.100.15 Changeset
@tanstack/vue-query 5.100.14 → 5.100.15 Changeset
@tanstack/angular-query-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/angular-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/eslint-plugin-query 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/preact-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/query-async-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/query-broadcast-client-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/query-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-persist-client-core 5.100.14 → 5.100.15 Dependent
@tanstack/query-sync-storage-persister 5.100.14 → 5.100.15 Dependent
@tanstack/react-query 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-next-experimental 5.100.14 → 5.100.15 Dependent
@tanstack/react-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-devtools 5.100.14 → 5.100.15 Dependent
@tanstack/solid-query-persist-client 5.100.14 → 5.100.15 Dependent
@tanstack/svelte-query 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-devtools 6.1.33 → 6.1.34 Dependent
@tanstack/svelte-query-persist-client 6.1.33 → 6.1.34 Dependent
@tanstack/vue-query-devtools 6.1.33 → 6.1.34 Dependent

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

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

github-actions Bot commented Jun 2, 2026

size-limit report 📦

Path Size
react full 12.11 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon self-assigned this Jun 2, 2026
@sukvvon sukvvon merged commit f167fa8 into main Jun 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 free to 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