-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: next
Are you sure you want to change the base?
Changes from all commits
4c30998
5317838
3518acb
4fb0546
8811ff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import { initTRPC } from '@trpc/server'; | ||
|
||
export const t = initTRPC.create(); | ||
|
||
export type $RootTypes = (typeof t)['_config']['$types']; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,9 @@ | |
// building factories which can produce common functionality over a homologous data source. | ||
// | ||
import type { RouterLike, UtilsLike } from '@trpc/react-query/shared'; | ||
import type { AnyTRPCProcedureBuilder } from '@trpc/server'; | ||
import { TRPCError } from '@trpc/server'; | ||
import type { | ||
AnyRootTypes, | ||
createBuilder, | ||
} from '@trpc/server/unstable-core-do-not-import'; | ||
import z from 'zod'; | ||
import type { $RootTypes } from './polymorphism.common'; | ||
import { t } from './polymorphism.common'; | ||
|
||
// | ||
|
@@ -33,10 +29,6 @@ export type FileExportStatusType = z.infer<typeof FileExportStatus>; | |
// Dependencies | ||
// | ||
|
||
type BaseProcedure<TRoot extends AnyRootTypes> = ReturnType< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
typeof createBuilder<TRoot['ctx'], TRoot['meta']> | ||
>; | ||
|
||
export type DataProvider = FileExportStatusType[]; | ||
|
||
// | ||
|
@@ -47,7 +39,7 @@ export type DataProvider = FileExportStatusType[]; | |
let COUNTER = 1; | ||
|
||
export function createExportRoute< | ||
TBaseProcedure extends BaseProcedure<$RootTypes>, | ||
TBaseProcedure extends AnyTRPCProcedureBuilder, | ||
>(baseProcedure: TBaseProcedure, dataProvider: DataProvider) { | ||
return t.router({ | ||
start: baseProcedure | ||
|
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.
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:
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
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.
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