-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: infinite query types #6571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes update several type definitions and interface signatures across the project to improve type safety with tRPC and infinite query functionality. New types such as Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
π Recent review detailsConfiguration used: CodeRabbit UI π Files selected for processing (1)
β° Context from checks skipped due to timeout of 90000ms (19)
π Additional comments (1)
β¨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
π Deployed to the trpc-pr-6571 environment in trpc-sse-and-websockets
|
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
1 Skipped Deployment
|
@trpc/client
@trpc/next
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
5f6883f to
4c8a0ca
Compare
4c8a0ca to
520ee0d
Compare
520ee0d to
034fcdb
Compare
| TRPCClientErrorLike<{ | ||
| transformer: TDef['transformer']; | ||
| errorShape: TDef['errorShape']; | ||
| }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a boomer so I'm testing to leave a comment from vscode here
KATT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely to do this through cursor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
packages/tanstack-react-query/src/internals/infiniteQueryOptions.ts (1)
206-210: Broader generics for infinite options.Switching from
unknowntoanyincreases flexibility when passing diverse data shapes, but be mindful thatanycan reduce strict type checks.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (6)
packages/tanstack-react-query/src/internals/createOptionsProxy.ts(6 hunks)packages/tanstack-react-query/src/internals/infiniteQueryOptions.ts(8 hunks)packages/tanstack-react-query/src/internals/types.ts(2 hunks)packages/tanstack-react-query/test/infiniteQueryOptions.test.tsx(4 hunks)packages/tanstack-react-query/test/queryKeyable.test.tsx(3 hunks)packages/tanstack-react-query/test/queryOptions.test.tsx(2 hunks)
π§ Files skipped from review as they are similar to previous changes (2)
- packages/tanstack-react-query/test/infiniteQueryOptions.test.tsx
- packages/tanstack-react-query/src/internals/createOptionsProxy.ts
β° Context from checks skipped due to timeout of 90000ms (18)
- GitHub Check: E2E-tests (fastify-server)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
- GitHub Check: E2E-tests (express-server)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
- GitHub Check: E2E-tests (express-minimal)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
- GitHub Check: Release using pkg.pr.new
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
- GitHub Check: E2E-tests (.test/ssg)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
- GitHub Check: E2E-tests (.test/internal-types-export)
- GitHub Check: Test a monorepo using built declaration files
- GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
- GitHub Check: E2E-tests (.test/diagnostics-big-router)
- GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
- GitHub Check: E2E-tests (.experimental/next-app-dir)
- GitHub Check: E2E-tests (Deno) (deno-deploy)
- GitHub Check: test
π Additional comments (19)
packages/tanstack-react-query/src/internals/types.ts (2)
1-1: Import is correct.Importing
InfiniteDatafrom@tanstack/react-queryis properly aligned with its usage below.
35-41: Introducing a specialized infinite query type.Defining
TRPCInfiniteDataas a specialized version ofInfiniteData<TOutput, NonNullable<ExtractCursorType<TInput>> | null>fortifies type safety around infinite queries and cursors.packages/tanstack-react-query/test/queryOptions.test.tsx (2)
4-5: New imports for error shape consistency.Importing
TRPCClientErrorLikeandinferRouterErrorensures that tests conform to the revised error structure.
73-76: Explicitly verifying the error shape.Validating that
query1.errorisTRPCClientErrorLike<{ transformer: false; errorShape: inferRouterError<typeof ctx.router>; }>adds clarity and reliability in type checks.packages/tanstack-react-query/test/queryKeyable.test.tsx (3)
3-4: Added TRPCError imports.These imports prepare for error type refinements, aligning with the new error shape strategy.
266-273: Improved error typing.Switching to
TRPCClientErrorLikeclarifies potential error structures, facilitating better error handling in queries.
300-307: Consistent error shape usage.Applying the same error typing reaffirms a stronger and uniform approach to runtime error handling across the codebase.
packages/tanstack-react-query/src/internals/infiniteQueryOptions.ts (12)
16-16: Referencing TRPCInfiniteData.Leveraging
TRPCInfiniteDatain the imports ensures alignment with your specialized infinite query data structure.
39-39: Revised TQueryFnData reference.Replacing the plain
TDatatype withTRPCInfiniteData<TInput, TData>enhances clarity around infinite query paging.
58-58: Incorporating TRPCInfiniteData.This enforces a fully typed structure for paginated data within undefined-initial-data options.
65-65: Aligned queryKey type.Referencing
TRPCInfiniteData<TInput, TData>withinqueryKeyprovides stronger type alignment for infinite queries.
74-74: Updating TData in defined-initial-data options.Switching to
TRPCInfiniteData<TInput, TData>keeps all infinite query definitions consistent.
93-93: Consistent approach to data shaping.Continuing
TRPCInfiniteDatausage avoids mixing different shapes in the same infinite query logic.
100-100: queryKey upgrade with infinite data.Using
TRPCInfiniteDatain thequeryKeyproperty ensures consistent referencing of typed infinite query results.
113-113: Enforcing typed infinite results.Referencing
TRPCInfiniteDataclarifies the return shape within skip-token-based infinite queries.
132-132: Streamlined page-param type.Aligning the cursor structure with
TRPCInfiniteDatahelps maintain correctness when advancing infinite query pages.
139-139: Specifically typed queryKey.Using
TRPCInfiniteData<TInput, TData>ensures a cohesive link between the data source and the query key itself.
150-153: More precise error typing.Defining
TRPCClientErrorLikewith explicittransformeranderrorShapeparameters clarifies error states for infinite queries.
160-163: Reinforcing error structure.Applying the same
TRPCClientErrorLikepattern across all overloads fosters uniform error handling.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes #
π― Changes
What changes are made in this PR? Is it a feature or a bug fix?
β Checklist
Summary by CodeRabbit
New Features
Refactor
Tests