sugar_water
sugar_water2y ago

Separating routers into their own modules and merging them causes "any" type in client

Hi all, I've separated my router into multiple files, but when merging them I get any types for all procedures in the client. This happens with both mergeRouters and composing a parent router with multiple child routers. It seems like trpc is loosing type information... I've verified that both my client and server trpc have the same version, 10.23.0, and that my typescript configuration is correct according to the docs. My environment is: node: v19.2.0 npm 8.19.3 Anyone know what's up with this? Thanks!
5 Replies
Nick
Nick2y ago
Have you reloaded your typescript server? Could you share some of the relevant code?
kevin.hill.fortunabmc
Hello, I hope its ok to revive this, with a possibly similiar question... I had / have a nextjs app with a very large router, and I thought it would be a good idea to break it apart into a monorepo because I wanted to be able to create more than one app, with the same api
kevin.hill.fortunabmc
GitHub
GitHub - clerkinc/t3-turbo-and-clerk: A t3 Turbo starter with Clerk...
A t3 Turbo starter with Clerk as the auth provider. - GitHub - clerkinc/t3-turbo-and-clerk: A t3 Turbo starter with Clerk as the auth provider.
kevin.hill.fortunabmc
and then I broke apart my router into their respective service routers (example, I have a large Asana router, and Dropbox, and Salesforce....) I made each "service" a module in the monorepo, because they also have components and other "service" specific things.... now here is my issue.... how can I build up the big router, from the different modules? I keep running into issues where I can't export "router" from api to each service and add to the router, because then I have to import it back and that's a cycle... So I thought maybe I can import the clients from the services, build middlewares in api and export procedures.... but then I still need to use router from api to build up the whole thing..... Is what I am trying to do even possible? does the whole, complete router need to be exported in one shot? Can I even have external modules bring functionality into the tRPC router? I feel like I must be missing something....
sugar_water
sugar_water2y ago
Hello, replying back late. Issue was I was using the "Volar" extension in VSCode (since this is a Vue project). I fixed the issue by disabling the extension