Skip to content

test(lit-query/createQueryController): add type tests - #11765

Open
sukvvon wants to merge 2 commits into
mainfrom
test/lit-query-create-query-controller-type-tests
Open

sukvvon wants to merge 2 commits into
mainfrom
test/lit-query-create-query-controller-type-tests

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

Adds createQueryController.test-d.ts with 19 type tests for the result of createQueryController:

  • data and error inferred from the query function, from explicit type parameters, from a union result, from a generic query function, and from a typed QueryFunction key
  • a query function whose result doesn't match the specified type is rejected
  • wrapped queries and custom controllers built on CreateQueryOptions
  • narrowing data and error through isPending, isLoadingError, isSuccess, and a discriminated union
  • initialData from a function that can return undefined, select over spread queryOptions, structuralSharing with unknown types, and generic indexed-access TData

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 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

  • Tests
    • Expanded automated checks for query configuration, type inference, and result-state handling.

@sukvvon sukvvon self-assigned this Sep 30, 2026
@nx-cloud

nx-cloud Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2352815

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

☁️ Nx Cloud last updated this comment at 2026-09-30 17:07:56 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 2352815

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8b984661-d018-450b-8e18-a2b3f6ed288e

📥 Commits

Reviewing files that changed from the base of the PR and between 7636fc5 and 2352815.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7fc6f680-dc70-4dd2-8e6f-4e4cf12020c8

📥 Commits

Reviewing files that changed from the base of the PR and between d374547 and 7636fc5.

📒 Files selected for processing (1)
  • packages/lit-query/src/__tests__/createQueryController.test-d.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

This change adds compile-time tests for createQueryController. The tests cover type inference, query options, result-state narrowing, initial data, structural sharing, and generic indexed-access data.

Changes

Query controller type tests

Layer / File(s) Summary
Query and fetcher type inference
packages/lit-query/src/__tests__/createQueryController.test-d.ts
Tests default, inferred, explicit, union, and generic result types. Also checks query-key inference and wrapped fetcher options.
Result-state and initial data narrowing
packages/lit-query/src/__tests__/createQueryController.test-d.ts
Checks data types across result states, select results, initial data, and discriminated unions.
Option and generic data typing
packages/lit-query/src/__tests__/createQueryController.test-d.ts
Checks custom controller options, structural sharing types, and generic indexed-access data.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 7636f

This change adds type tests only and does not alter runtime behavior. It carries no identified merge risk.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. 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 clearly and concisely states that the pull request adds type tests for createQueryController.
Description check ✅ Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains the 19 type tests, records completed checklist items, and identifies the change as docs/CI/dev-only.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

This branch has not been deployed

No deployments
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