Skip to content

Conversation

@cooolbros
Copy link

@cooolbros cooolbros commented Jun 3, 2025

🎯 Changes

Export types SubscriptionResolver and ResolverDef (because of generic type argument TDef extends ResolverDef)

Both exported types are marked as @internal

Previously, only type Resolver was exported, but not SubscriptionResolver

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

Summary by CodeRabbit

  • Documentation
    • Clarified and renamed internal type annotations and updated related internal typings to improve code clarity for developers. No functional or user-facing changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@cooolbros cooolbros requested a review from a team as a code owner June 3, 2025 05:15
@vercel
Copy link

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
next-prisma-starter Ready Ready Preview Dec 19, 2025 11:34am
og-image Ready Ready Preview, Comment Dec 19, 2025 11:34am
www Ready Ready Preview, Comment Dec 19, 2025 11:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

Walkthrough

Renamed the internal type ResolverDef to TRPCResolverDef and exported it. Updated generic constraints in Resolver, SubscriptionResolver, and DecorateProcedure to use TRPCResolverDef. Marked SubscriptionResolver with @internal and exported it from packages/client/src/createTRPCClient.ts.

Changes

Cohort / File(s) Change Summary
Type & generics update
packages/client/src/createTRPCClient.ts
Renamed ResolverDef to exported TRPCResolverDef; updated Resolver<TDef>, SubscriptionResolver<TDef>, and DecorateProcedure<... , TDef> to constrain TDef with TRPCResolverDef; added /** @internal */ JSDoc to and exported SubscriptionResolver.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Pay attention to exported API surface changes in packages/client/src/createTRPCClient.ts.
  • Verify downstream uses/type imports of ResolverDef elsewhere in the codebase.

Possibly related PRs

Poem

I nibble on types in the pale moonlight,
TRPC roots tidy, everything just right.
A renamed burrow, a tiny export gate,
Rabbity hops keep the types up to date.
🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: exporting two types (SubscriptionResolver and ResolverDef), which aligns with the actual changeset.
Description check ✅ Passed The description includes all required template sections with meaningful content, explains the rationale for changes, and indicates checklist completion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd5ad1 and 4c3c0fe.

📒 Files selected for processing (1)
  • packages/client/src/createTRPCClient.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Always use import type for type-only imports
Separate type imports from value imports
Avoid overzealous object destructuring; prefer direct property access
Object destructuring is acceptable when a variable is used 3+ times
Prefer array destructuring
Avoid sparse array destructuring
Never destructure in function parameter declarations
Avoid destructuring potentially nullish nested properties
Maximum 3 parameters per function; use options objects when more
Type parameter names must match /^(T|$)(A-Z)?[0-9]*$/
Prefix unused variables, parameters, and caught errors with _
Prefer namespace imports for validation libraries and large modules (e.g., import * as z from 'zod', import * as React from 'react')
Follow import order: test helpers, tRPC test imports, third-party, then relative
Never import from @trpc/*/src; import from the package root instead
Do not use Symbol.dispose or Symbol.asyncDispose; use makeResource()/makeAsyncResource()
Always use await using for resource cleanup
Prefer makeResource()/makeAsyncResource() over manual disposal logic
Avoid non-null assertions (!)
Use proper type guards and optional chaining instead of non-null assertions
Switch statements must be exhaustive for union types
Rely on TypeScript inference; avoid unnecessary explicit return/output types
Use explicit types at public API boundaries, for complex generic constraints, or when inference is insufficient/ambiguous
Use the satisfies operator to retain inference while enforcing shapes
Use as const for literal type inference when appropriate
Prefer explicit typing over any
Use type assertions sparingly
Leverage TypeScript strict mode features

Files:

  • packages/client/src/createTRPCClient.ts
**/*.{ts,tsx,md,mdx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use camelCase for file names (with exceptions like TRPC/RPC/HTTP/JSON acronyms, .config.js, .d.ts, and tests)

Files:

  • packages/client/src/createTRPCClient.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

No console.log in packages; use proper logging instead

Files:

  • packages/client/src/createTRPCClient.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: barelyhuman
Repo: trpc/trpc PR: 6530
File: packages/upgrade/src/bin/cli.ts:218-222
Timestamp: 2025-02-19T20:31:52.088Z
Learning: The CLI options `trpcFile` and `trpcImportName` in `packages/upgrade/src/bin/cli.ts` are temporary and planned to be removed in favor of using automatically discovered references from the TypeScript program.
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-09-05T16:48:06.982Z
Learning: Share common functionality through `trpc/server` and keep client/server concerns separate
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-09-05T16:48:06.982Z
Learning: Applies to **/*.{ts,tsx} : Never import from `trpc/*/src`; import from the package root instead
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/upgrade-tests.mdc:0-0
Timestamp: 2025-09-05T15:17:32.520Z
Learning: Applies to packages/upgrade/**/*.{test,spec,trpc,snap}.tsx : Import both 'trpc/react-query' as rq (legacy) and 'trpc/tanstack-react-query' as trq (modern) when writing migration tests
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/tanstack-react-query-tests.mdc:0-0
Timestamp: 2025-09-05T15:16:31.379Z
Learning: Applies to packages/tanstack-react-query/**/*.test.tsx : Use `ctx.useTRPCClient()` for direct (vanilla) tRPC client access in tests
📚 Learning: 2025-02-19T20:31:52.088Z
Learnt from: barelyhuman
Repo: trpc/trpc PR: 6530
File: packages/upgrade/src/bin/cli.ts:218-222
Timestamp: 2025-02-19T20:31:52.088Z
Learning: The CLI options `trpcFile` and `trpcImportName` in `packages/upgrade/src/bin/cli.ts` are temporary and planned to be removed in favor of using automatically discovered references from the TypeScript program.

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:17:32.520Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/upgrade-tests.mdc:0-0
Timestamp: 2025-09-05T15:17:32.520Z
Learning: Applies to packages/upgrade/**/*.{test,spec,trpc,snap}.tsx : Import both 'trpc/react-query' as rq (legacy) and 'trpc/tanstack-react-query' as trq (modern) when writing migration tests

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T16:48:06.982Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-09-05T16:48:06.982Z
Learning: Applies to **/*.{ts,tsx} : Never import from `trpc/*/src`; import from the package root instead

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:16:31.379Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/tanstack-react-query-tests.mdc:0-0
Timestamp: 2025-09-05T15:16:31.379Z
Learning: Applies to packages/tanstack-react-query/**/*.test.tsx : Use `ctx.useTRPCClient()` for direct (vanilla) tRPC client access in tests

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T16:48:06.982Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-09-05T16:48:06.982Z
Learning: Share common functionality through `trpc/server` and keep client/server concerns separate

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:16:01.878Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/react-query-tests.mdc:0-0
Timestamp: 2025-09-05T15:16:01.878Z
Learning: Applies to packages/react-query/**/*.test.tsx : Import createTRPCReact from 'trpc/react-query' (legacy API)

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:16:01.878Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/react-query-tests.mdc:0-0
Timestamp: 2025-09-05T15:16:01.878Z
Learning: Applies to packages/react-query/**/*.test.tsx : Create the tRPC React client with createTRPCReact<typeof appRouter>()

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:16:01.878Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/react-query-tests.mdc:0-0
Timestamp: 2025-09-05T15:16:01.878Z
Learning: Applies to packages/react-query/**/*.test.tsx : Import getUntypedClient from 'trpc/client' when an untyped client is needed

Applied to files:

  • packages/client/src/createTRPCClient.ts
📚 Learning: 2025-09-05T15:17:32.520Z
Learnt from: CR
Repo: trpc/trpc PR: 0
File: .cursor/rules/upgrade-tests.mdc:0-0
Timestamp: 2025-09-05T15:17:32.520Z
Learning: Applies to packages/upgrade/**/*.{test,spec,trpc,snap}.tsx : For migration testing, exercise both legacy and modern patterns via ctx.rq and ctx.trq within the same test when relevant

Applied to files:

  • packages/client/src/createTRPCClient.ts
🧬 Code graph analysis (1)
packages/client/src/createTRPCClient.ts (1)
packages/client/src/internals/types.ts (1)
  • TRPCProcedureOptions (95-101)
🔇 Additional comments (5)
packages/client/src/createTRPCClient.ts (5)

50-56: LGTM! Type renamed and exported as requested.

The rename to TRPCResolverDef with the @internal annotation matches the maintainer feedback and follows the project's naming convention for internal types. The export enables cross-package usage while clearly signaling this is not part of the public API.


64-64: Constraint correctly updated for consistency.

The generic constraint properly references the renamed TRPCResolverDef type.


69-76: SubscriptionResolver successfully exported as intended.

The export with @internal annotation and updated constraint achieves the PR objective. This allows the type to be used across packages while maintaining its internal status.


80-80: Constraint correctly updated.

The generic constraint properly uses the renamed TRPCResolverDef type, maintaining consistency across the file.


50-80: The concern about lingering references is unfounded.

The verification reveals that ResolverDef references in other packages (tanstack-react-query, react-query, next) are separate, locally-scoped type definitions within each package—not references to the type renamed in packages/client/src/createTRPCClient.ts. Each package maintains its own ResolverDef type definition independent of the others. The rename to TRPCResolverDef in the client package is complete within its intended scope and does not require updates across separate packages.

Likely an incorrect or invalid review comment.


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.

@vercel
Copy link

vercel bot commented Jun 3, 2025

@cooolbros is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 3, 2025

Open in StackBlitz

@trpc/client

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6803

@trpc/next

npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6803

@trpc/react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6803

@trpc/server

npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6803

@trpc/tanstack-react-query

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

@trpc/upgrade

npm i https://pkg.pr.new/trpc/trpc/@trpc/upgrade@6803

commit: 4c3c0fe

Nick-Lucas
Nick-Lucas previously approved these changes Jun 3, 2025
KATT
KATT previously approved these changes Sep 22, 2025
Co-authored-by: Alex / KATT <alexander@n1s.se>
auto-merge was automatically disabled December 19, 2025 11:33

Head branch was pushed to by a user without write access

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.

4 participants