Skip to content
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

Export AnyTRPCProcedureBuilder from @trpc/server #5497

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

ymc9
Copy link

@ymc9 ymc9 commented Feb 19, 2024

Closes #

🎯 Changes

What changes are made in this PR? Is it a feature or a bug fix?

✅ Checklist

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

@ymc9 ymc9 requested a review from a team as a code owner February 19, 2024 04:38
Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
trpc-next-app-dir ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 5:13am
www ❌ Failed (Inspect) Feb 19, 2024 5:13am

Copy link

vercel bot commented Feb 19, 2024

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

A member of the Team first needs to authorize it.

@ymc9
Copy link
Author

ymc9 commented Feb 19, 2024

An E2E test case is failing, but it doesn't seem to relate to the changes made. I can't reproduce the failure locally either.

UnsetMarker,
UnsetMarker,
UnsetMarker,
UnsetMarker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm basically 100% sure this is going to cause regressions which our test suite may not be capturing yet (because we never broke it before)

Here's the reason: https://trpc.io/docs/server/validators#input-merging

and here's the scenario:

image

It's totally valid to set up an input or output and then create a router with that procedure, so UnsetMarker wouldn't be the root type in that situation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so as per https://github.com/trpc/trpc/pull/5497/files#r1494523733 I think what we could do is leave this AnyProcedureBuilder be

If you copy it over to packages/react-query/src/shared/polymorphism and export it from there though, I think we can live with its shortcomings as a limitation and open it up later. But we shouldn't make the rest of the codebase live with UnsetMarker hard-coded

@@ -33,10 +29,6 @@ export type FileExportStatusType = z.infer<typeof FileExportStatus>;
// Dependencies
//

type BaseProcedure<TRoot extends AnyRootTypes> = ReturnType<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly what was here before actually does produce a type with typeof unsetMarker there, so inter-compat with .input merging wouldn't work in production today for router factories. Maybe we can find a compromise then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried export this from @trpc/server basically and found the same problem popped up with procedure.input() being passed through

// type $RootTypes = ReturnType<typeof initTRPC.create>['_config']['$types'];
// export type AnyTRPCProcedureBuilder = ReturnType<
//   typeof createBuilder<$RootTypes['ctx'], $RootTypes['meta']>
// >;

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.

None yet

2 participants