Skip to content

test({vue,svelte}-query): add type tests for inferring the result type from a generic 'queryFn' - #11464

Merged
sukvvon merged 2 commits into
mainfrom
test/vue-svelte-query-generic-queryfn-type-inference
Sep 10, 2026
Merged

test({vue,svelte}-query): add type tests for inferring the result type from a generic 'queryFn'#11464
sukvvon merged 2 commits into
mainfrom
test/vue-svelte-query-generic-queryfn-type-inference

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 9, 2026

Copy link
Copy Markdown
Member

🎯 Changes

vue-query and svelte-query were the only adapters without a type test covering result type inference through a generic queryFn. react-query, preact-query, solid-query, and angular-query-experimental all assert this in their useQuery/injectQuery type tests, so this brings the two remaining adapters in line.

Each new test declares a generic function whose type parameter defaults to string, passes it as the queryFn, and asserts that the default propagates to data:

function queryFn<T = string>(): Promise<T> {
  return Promise.resolve({} as T)
}
  • packages/vue-query/src/__tests__/useQuery.test-d.ts — new generic queryFn describe, placed before generic queryKey inference (#8199) so the queryFn case precedes the queryKey one.
  • packages/svelte-query/tests/createQuery/createQuery.test-d.ts — new generic queryFn describe as a sibling of the existing initialData block.

Both assert data is string | undefined and error is Error | null, matching the assertions the other adapters already make.

Type tests only — no runtime or published code is touched.

✅ 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 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
    • Added coverage to verify correct type inference for generic query functions.
    • Confirmed query data resolves to the expected value type and query errors retain the expected error type.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 24a31afa-2aa4-44d8-951c-878a8432afa0

📥 Commits

Reviewing files that changed from the base of the PR and between c07c1f5 and b0b6581.

📒 Files selected for processing (2)
  • packages/svelte-query/tests/createQuery/createQuery.test-d.ts
  • packages/vue-query/src/__tests__/useQuery.test-d.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds type-level tests for generic query functions in Svelte Query and Vue Query. The tests verify inferred string | undefined data and Error | null error types.

Changes

Generic query inference

Layer / File(s) Summary
Query function inference validation
packages/svelte-query/tests/createQuery/createQuery.test-d.ts, packages/vue-query/src/__tests__/useQuery.test-d.ts
Adds type-level tests for generic query functions with a default string type. The tests assert query.data as `string

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b0b65

This adds Vue and Svelte type coverage confirming generic query functions infer string data and nullable query errors as expected. It does not change runtime behavior or published APIs, and no merge-blocking risk remains.

Suggested reviewers: ousamabenyounes

🚥 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 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the addition of type tests for generic queryFn result-type inference in the Vue and Svelte Query adapters.
Description check ✅ Passed The description explains the motivation, files changed, test behavior, validation checklist, and release impact. It matches the required template and identifies the change as test-only with no changes…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/vue-svelte-query-generic-queryfn-type-inference

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.

@sukvvon sukvvon self-assigned this Sep 9, 2026
@sukvvon sukvvon changed the title test(vue-query/svelte-query): add type tests for inferring the result type from a generic 'queryFn' test({vue,svelte}-query): add type tests for inferring the result type from a generic 'queryFn' Sep 9, 2026
@nx-cloud

nx-cloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b0b6581

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

☁️ Nx Cloud last updated this comment at 2026-09-10 00:01:41 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: b0b6581

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.85 KB (0%)
react minimal 8.84 KB (0%)

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 23 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/query-core 5.102.8 → 5.103.0 Changeset
@tanstack/svelte-query 6.1.48 → 6.2.0 Changeset
@tanstack/angular-query-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/angular-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/eslint-plugin-query 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/query-async-storage-persister 5.102.8 → 5.103.0 Dependent
@tanstack/query-broadcast-client-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/query-persist-client-core 5.102.8 → 5.103.0 Dependent
@tanstack/query-sync-storage-persister 5.102.8 → 5.103.0 Dependent
@tanstack/react-query 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-next-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/svelte-query-devtools 6.1.48 → 6.2.0 Dependent
@tanstack/svelte-query-persist-client 6.1.48 → 6.2.0 Dependent
@tanstack/vue-query 5.102.8 → 5.103.0 Dependent
@tanstack/vue-query-devtools 6.1.48 → 6.2.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.20 → 0.2.21 Dependent

@sukvvon
sukvvon merged commit 7452ef6 into main Sep 10, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/vue-svelte-query-generic-queryfn-type-inference branch September 10, 2026 00: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