The inferred type of this node exceeds the maximum length the compiler will serialize.
Hey, there I am running into this error when I have more than 12 routers in the mergeRouters function.
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
version: latest
related: https://github.com/trpc/trpc/issues/2568 // that din't work for me.GitHub
[v10] bug: TypeScript not willing to serialize the type of my clien...
Provide environment information System: OS: macOS 12.5 CPU: (10) arm64 Apple M1 Pro Memory: 152.64 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/...
N
Nick•412d ago
Are you able to share your code?
H
Hussam•412d ago
it's a private repo, I can share snippet if you like to.
I am referring to cal.com setup, my local setup for cal.com also error out the same way.
https://github.com/calcom/cal.com/blob/main/packages/trpc/server/routers/viewer.tsx#LL1281C20-L1281C20,
uncommenting any of the last three gives that type error on appRouter
N
Nick•412d ago
Interesting
I think it's worth opening a fresh issue for this, but it would be very helpful to have a reproduction repo
H
Hussam•412d ago
Oh and I forgot to mention,
it works when I set
declaration: false
in tsconfig.json
.
I dont know, if that's okay or will have cons for itN
Nick•412d ago
Just to be sure, do you have strict:true enabled?
That can help a lot of perf things
H
Hussam•412d ago
yup, it's set to true
N
Nick•412d ago
Great
I'd open a GitHub issue then
H
Hussam•412d ago
sure, thanks.
T
trash•412d ago
in the past we have recommended turning off that option if you dont need it
https://www.typescriptlang.org/tsconfig#declaration
tldr; it generate a d.ts file for every file. which is unnecessary in most cases
MS
mark salsbery•412d ago
Just for my own sanity, why are you merging 2 un-namespaced routers with the second one an already merged set of namespaced routers?
H
Hussam•412d ago
just so that I get to question right
Did you mean I could do this instead ?
I followed this setup,
https://github.com/calcom/cal.com/blob/main/packages/trpc/server/routers/viewer.tsx#LL1281C20-L1281C20,
Also, thanks you made me realize
router()
is Deprecated
https://trpc.io/docs/typedoc/server/functions/router-1#deprecatedMS
mark salsbery•411d ago
Yes that’s what i meant…or use router({…}) for namespaced endpoints. I’ve never seen the two mixed so I’m curious
https://trpc.io/docs/server/merging-routers#merging-with-tmergerouters
Merging Routers | tRPC
Writing all API-code in your code in the same file is not a great idea. It's easy to merge routers with other routers.
H
Hussam•411d ago
I moved everything into
router({ })
, and the type error is gone.
Just a head ups @Nick Lucas, it's fixed for me now. I hadn't created a github issue, as I couldn't reproduce the issue easily.
thanks a lot all of you.4.8KMembers
View on DiscordMore Posts
Quickstart not workingHello there,
There is a type error in the quickstart example if i'm not mistaken.
I pretty much coUse TRPC function inside of a TRPC functionHi all! We have a trpc query called getProduct. I want to use this getProduct query inside of anotheSupabase with trpcWhen trying to configure trpc with supabase, getting this kind of error in the console
`tRPC failed Using tRPC for uploading audio filesI want to create an api router in tRPC but am not sure if the following code is doable with tRPC. IfEnigmatic INTERNAL SERVER ERRORIm having a problem finding out about what is causing the INTERNAL SERVER ERROR from tRPC in my prodcreateProxySSGHelpers type errorHi all! Anyone know how to use createProxySSGHelpers with appropriate createContext typing?Can I force metadata with the createCaller?I have custom metadata which I check within the middleware. Im trying to write tests for this. CurreVitest error testHow can I test for specific TRPCError code with vitest? I managed to get the message but can't figurUsing generics duplicates the types instead of referring to the existing typesHi!
I'm creating a backend API using TRPC, where I'm encountering a slight problem. TL;DR; when defSet custom header for fetchRequestHandlerIs this possible? currently getting cors issue. Trying to use nextjs's edge function with trpc..
``How to enforce usequery as NonNullableI have a custom hook with infinite query. I check for undefined at the app first render and then it How to call useQuery with params inside JSXHow can i achieve this? Thanks
```
export function MemberQueryList({ list }: Props) {
function Sharing EnumOn the backend: I have colocated files with types and procedures (index.ts - procedures, schemas.ts Meta - unable to create default metaTrying to follow https://trpc.io/docs/server/metadata#default-meta-chaining-and-shallow-merging
I setrpc/react-query batchingHi. How do you deal with batching? If I don't put any maxURLLength then I get an error 404 since it middleware error with minimal-react examplehello! I tried to use the minimal-react version, but I get an error - it says that `'middleware'` dohow to use the same Zod validation both client and server's procedure inputWhen submitting forms, I need the same validation. How to reduce the repeated code?pipe/unstable_pipeI cant seem to find it? according to the docs I can chain middlewares using pipe in v10 but the featImplementation of bi-directional cursor-based paginationI'm looking at the [example](https://trpc.io/docs/useInfiniteQuery#example-react-component) for `useHow to ignore `input` validation and just pass in an object with interfaces?For my input I just want to pass in an interface rather than using a Zod schema. Either that or if s