Skip to content

fix(preact-query): infer infinite pageParam in useInfiniteQuery return type#10840

Closed
raashish1601 wants to merge 2 commits into
TanStack:mainfrom
raashish1601:fix/preact-infinite-query-pageparam-types
Closed

fix(preact-query): infer infinite pageParam in useInfiniteQuery return type#10840
raashish1601 wants to merge 2 commits into
TanStack:mainfrom
raashish1601:fix/preact-infinite-query-pageparam-types

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 30, 2026

test

Summary by CodeRabbit

  • Bug Fixes

    • Improved TypeScript type inference for useInfiniteQuery to correctly resolve page parameter types, providing better type safety when working with infinite queries.
  • Chores

    • Optimized code coverage collection to run only in CI environments, reducing local development build overhead.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab20db12-f627-42ec-ac2c-de25a84a95bf

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa2781 and 1fc175e.

📒 Files selected for processing (26)
  • packages/angular-query-experimental/vite.config.ts
  • packages/angular-query-persist-client/vite.config.ts
  • packages/eslint-plugin-query/vite.config.ts
  • packages/preact-query-devtools/vite.config.ts
  • packages/preact-query-persist-client/vite.config.ts
  • packages/preact-query/src/__tests__/useInfiniteQuery.test-d.tsx
  • packages/preact-query/src/useInfiniteQuery.ts
  • packages/preact-query/vite.config.ts
  • packages/query-async-storage-persister/vite.config.ts
  • packages/query-broadcast-client-experimental/vite.config.ts
  • packages/query-codemods/vite.config.ts
  • packages/query-core/vite.config.ts
  • packages/query-devtools/vite.config.ts
  • packages/query-persist-client-core/vite.config.ts
  • packages/query-sync-storage-persister/vite.config.ts
  • packages/query-test-utils/vite.config.ts
  • packages/react-query-devtools/vite.config.ts
  • packages/react-query-persist-client/vite.config.ts
  • packages/react-query/vite.config.ts
  • packages/solid-query-devtools/vite.config.ts
  • packages/solid-query-persist-client/vite.config.ts
  • packages/solid-query/vite.config.ts
  • packages/svelte-query-devtools/vite.config.ts
  • packages/svelte-query/vite.config.ts
  • packages/vue-query-devtools/vite.config.ts
  • packages/vue-query/vite.config.ts

📝 Walkthrough

Walkthrough

The PR applies two independent changes: it gates Vitest code coverage to CI environments across the monorepo's 23+ packages via vite.config.ts files, and it improves TypeScript type inference for Preact's useInfiniteQuery hook to correctly resolve page parameter types instead of defaulting to unknown.

Changes

CI-Gated Test Coverage

Layer / File(s) Summary
Coverage enabled conditionally across vite.config.ts files
packages/angular-query-experimental/vite.config.ts, packages/angular-query-persist-client/vite.config.ts, packages/eslint-plugin-query/vite.config.ts, packages/preact-query-devtools/vite.config.ts, packages/preact-query-persist-client/vite.config.ts, packages/preact-query/vite.config.ts, packages/query-async-storage-persister/vite.config.ts, packages/query-broadcast-client-experimental/vite.config.ts, packages/query-codemods/vite.config.ts, packages/query-core/vite.config.ts, packages/query-devtools/vite.config.ts, packages/query-persist-client-core/vite.config.ts, packages/query-sync-storage-persister/vite.config.ts, packages/query-test-utils/vite.config.ts, packages/react-query-devtools/vite.config.ts, packages/react-query-persist-client/vite.config.ts, packages/react-query/vite.config.ts, packages/solid-query-devtools/vite.config.ts, packages/solid-query-persist-client/vite.config.ts, packages/solid-query/vite.config.ts, packages/svelte-query-devtools/vite.config.ts, packages/svelte-query/vite.config.ts, packages/vue-query-devtools/vite.config.ts, packages/vue-query/vite.config.ts
All vite.config.ts files set test.coverage.enabled to !!process.env.CI instead of hardcoded true. A few files also reorder imports to add packageJson import statements.

Preact Query InfiniteQuery Type Inference

Layer / File(s) Summary
Type helper logic for page parameter resolution
packages/preact-query/src/useInfiniteQuery.ts
IsUnknown and ResolvePageParamData conditional type helpers are added to resolve the effective data type when page-param type inference would default to unknown. All three function overloads' return types apply ResolvePageParamData<TQueryFnData, TData, TPageParam> instead of bare TData.
Type test expectations for page parameter inference
packages/preact-query/src/__tests__/useInfiniteQuery.test-d.tsx
Type assertions are updated to expect InfiniteData<T, number> instead of InfiniteData<T, unknown> when page parameters are concretely inferred. TODO comments about type limitations are removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • TanStack/query#10776: Disables local coverage instrumentation by switching Vitest test.coverage.enabled from hardcoded true to !!process.env.CI across multiple package configurations.

Suggested reviewers

  • TkDodo

🐰 Coverage now hides where it should,
Type inference understood!
CI runs tests with gleaming reports,
While locals skip the coverage courts.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@raashish1601
Copy link
Copy Markdown
Contributor Author

Superseded by PR 10841 with clean 2-file scoped commit against origin/main.

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