T3 Stack: tRPC not extending type definitions to client

Hey, I'm currently trying to work on getting my 'next build' script to work and ran into a bunch of issues when I'm using data from tRPC calls. The variables I'm saving the data under are not receiving the type inference benefits that I thought I would be getting with tRPC but instead being set to any type. To try and resolve this I looked into the tRPC docs and saw that you can use your root appRouter to create type inference from the subroute calls you make so I set about adding that to my application. It allowed me to get through all of the "unexepected any" errors with my next build script but out of the blue I started getting circular dependency issues with the tRPC type inference that I've built out and all of my tRPC calls on the client are now throwing errors. Has anyone experienced a similar issue or think they may have a solution as I have exhausted my own capabilities?
cje
cje33d ago
screenshots are not useful. gonna need a minimal reproduction to be able to tell you anything here.
Chuuy
Chuuy33d ago
I'm currently working off of this branch: https://github.com/gsayre/tournamate/tree/feature/tou-48. Sorry I don't know how to create a minimal reproduction as I don't fully understand what is happening here 😔 Almost all of my components in the components directory under src have some kind of tRPC call and I did my type inference exporting under server/trpc/exportedTypes.ts. Let me know if there is any other information that I can give to help for context
cje
cje33d ago
(watch the timestamp) The point of creating a minimal reproduction is that you figure out where it starts breaking
Chuuy
Chuuy33d ago
Sorry, I did not mean to offend or be inconsiderate in any way. This is my first time reaching out for help outside of work and first experience with any form of open source communication. I appreciate the explanation and your time to get this resource to me. I will get to work on trying to create a codesandbox or small example repo like detailed in the video after I finish work today. I appreciate the help and again I apologize if this came off the way described in the video
Chuuy
Chuuy32d ago
Hey, I created the minimal reproduction in codesandbox. It seems to be having some issues with the "@types/react" where the AppProps don't seem to be working but that is not an issue that I have in my repo. I think the important piece is that it is showing all of the errors that I'm experiencing with trpc in the virtual editor environment
cje
cje31d ago
on first look there are a bunch of issues that aren't related to your problem - _app.ts isn't importing helloRouter - trpc.ts refers to a context that doesn't exist - index.tsx refers to a procedure that doesn't exist on the router my suggestion would be pnpm create t3-app@latest, if you pick trpc, tailwind, and pages router it should be basically the same thing as your minimal repro, except it works. find the difference.
Chuuy
Chuuy27d ago
Hey, I appreciate all of your help but I don't think I'm getting anywhere with the issue after messing around with things for a couple days. I followed your suggestions and created a new t3-app@latest and then deprecated the versions to try and recreate the situation that I'm currently in and only found that a bunch of errors come from what I assume to be methods that exist in the v11 of tRPC and not in v10 which I'm currently on. Tried cleaning that up but ended up with the same error which I cannot pinpoint exactly where it comes from. From what I assume it has something to do with my _app.ts folder in my trpc server folder has an 'any' definition for the appRouter that we create and export to create the tRPCNextClient which will be consumed by the client side of my application. The router (from trpc.ts in trpc server directory) that I import in the _app.ts file is properly typed when I hover over with the BuiltRouter<etc...> but variable I am saving this router to, appRouter, has implicity a type of 'any'. This is where I believe the error to be occurring. I don't exactly know what I did to cause this but as a result I have tried doing patch, minor and major upgrades of tRPC using the "npx ncu" command and despite it being on an updated version of the library I am still getting these type errors where the appRouter is coming back as 'any' type.
Chuuy
Chuuy27d ago
I tried to do some more digging to see if anyone else was having issues with this error and found a couple pages and came across this page (https://github.com/trpc/trpc/issues/5614) which seems to include all of the reproductions similar to what I was experiencing except within a monorepo with a shared tRPC package instead of my create-t3-app. He mentions a bit about how there were problems probably caused by the fact he used commonjs in his server but I'm using esnext which is the suggested compiler option and still getting these issues. So I dug deeper into the linked issues (https://github.com/trpc/trpc/issues/3496). It seems he explicitly re-exported these types from the "trpc's unstable-core-do-not-import" package in his index.ts (https://github.com/akashdevcc/zero-stack/blob/main/packages/trpc/src/index.ts, lines 24-32) file which resolved those issues for him and caused the type inference issues to go away. I'm going to try the same thing and see if it resolves my problems as well and will report back because I've been pretty heads down on this just trying to get some kind of different error I can work off of. If that doesn't work then I'm going to create a new t3-turbo app and incrementally migrate all of my current project into the new one and hopefully through that I'll see where the problem may have been or maybe it will get resolved in a different project with updated dependencies.
GitHub
bug: Getting "property collision with a built-in method" in client ...
Provide environment information System: OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish) CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz Memory: 2.58 GB / 15.48 GB Container: Y...
GitHub
Issues · trpc/trpc
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - Issues · trpc/trpc
Chuuy
Chuuy27d ago
Thank you for all the help and I'll update this thread if I end up resolving the issue one way or another so that if someone else runs into the same issue they can stumble across this!
Want results from more Discord servers?
Add your server
More Posts
Total noob! Supabase and the t3 stackIm really struggling with configuring my create-t3-app with supabase. Can anyone point me in the dirHow to exclude specific routes from Clerk middleware?Anyone know how I can exclude the middleware from Clerk from running on my routes in folder: /api/crFor Sr+ Engineers: Frontend, Backend, or Full-stack?For the engineers that have been around a while, been successful in what they started with, and starIt works locally but doesn't save to the database when deployed on Vercel.It's working fine on my local machine, but after deploying to Vercel, it's not saving data to the daError on NextJs AppRouterAnyone knows why this is showing on my console?useFormState in tables, or complex formsI decided to play with the new server components and useFormState. I am building myself the table shHow are signals going to be any different that state variables in React?I was just watching Theo's videos on signals coming to javascript (https://www.youtube.com/watch?v=JNext redirect() gives date.getTime() errorI use lucia auth with nextjs. And all things are okay until i add `redirect('/blog/login')` fuction Prisma/tRPC query failing 1/2 the time, but only in ProdSo I have an app, in my local dev environment, everything is working as expected in regards to the DTailwind CSS dynamically add classesAre there docs or some guidelines on how the tailwind unused css class purging works exactly and howNo typesaftey for dynamic returns``` // BE publicProcedure.input(z.object({shouldPopulateRelation: z.boolean()})).query(({ input, ctxHow do you cache tRPC server responses w/Next App Router?**What is the correct way to define the cache for tRPC endpoints with `create-t3-app@7.30.1` & Next I want to get information from the indexedDB and include this in the first render, without delayThe issue is that react code needs to be hydrated before being executed, so you can't get info from getting error while fetching from uploadthingi am creating a next.js project where user can upload pdf file which we save using upload thing and Next Auth google says redirect URI is broken but works on another projectHi! I am working on a project and I keep getting the error: Access blocked: This app’s request is Next not doing SSG routes?? Am I missing something?Hi, I need to do this page ssg instead of dynamic server rendered, i dont have any dependencies so iHow to fix jupyterhub issueAnyone have any experience with jupyterhub? I'm getting: TimeoutError: pod jupyterhub/jupyter-zfjryP3005 Error running Prisma migrateI am working on a NextJS project that uses prisma. I was able to define my initial schemas and deploUTApi - server SDK uploadFilesFromUrl module errorI am getting a weird bug when uploading images using the utapi uploadFilesFromUrl. This is my serverVercel Date Issueunderstand that Vercel servers have different dates compared to the client's date. Typically, this i