T
tRPC

somehow when move typed function out of the router files, frontend infer type to be any ?

somehow when move typed function out of the router files, frontend infer type to be any ?

AEAhmed Eid10/10/2022
this is inferred corrected since they are in the same file.
getX: t.procedure.query(() => {
return getX()
})

function getX(): X{
...
}
getX: t.procedure.query(() => {
return getX()
})

function getX(): X{
...
}
getX: t.procedure.query(() => {
return getX()
})

export function getX(): X{ << moving this out of the file breaks the typing.
...
}
getX: t.procedure.query(() => {
return getX()
})

export function getX(): X{ << moving this out of the file breaks the typing.
...
}
which is a very weird issue.
Ssachin10/13/2022
not sure, probably unrelated to trpc
IItsWendell10/24/2022
@Ahmed Eid any solution found?
冰淇淋10/25/2022
What exactly do you refer as typing is broken? I think I got the same issue and my types result to any I made a repo that reproduces my issue, not sure its the same https://stackoverflow.com/questions/74185198/typescript-losing-zod-and-trpc-types-across-monorepo-projects-types-result-in
AEAhmed Eid12/10/2022
@ItsWendell I think I resolved it, if you're still facing this issue please let me know I think I can help you out.
IItsWendell12/10/2022
I have a simar issue with a turbo repository, where 'second hand' types are infered as any, e.g. I have a package with the TRPC API, which might return types from an external package. I use the TRPC package types in our app, but all types that are infered from external packages are any, all types that I give directly are fine. One solution I have is to use references in tsconfig like this:
{
"references": [
{
"path": "../../packages/api-service"
}
]
}
{
"references": [
{
"path": "../../packages/api-service"
}
]
}
BUT I believe this might have performance impact + it's annoying to have to think about adding this to every package that consumes the API service types

Looking for more? Join the community!

T
tRPC

somehow when move typed function out of the router files, frontend infer type to be any ?

Join Server
Recommended Posts
Big companies that use tRPC?Some of my fellow colleagues were wondering if there are any big companies that use tRPC and how matMigrating to V10 from V9If someone has some ideas on what I might have screwed up when trying to bump tRPC for this public sAuthentication broke after bump to v10 from v9Anyone that has any suggestions on what might have caused this? I get the following error when tryiShow a spinner when any mutation is loading?Looking to show an activity spinner in the header of our application whenever a mutation is in flighSharing schemas between server and clientIn a typical nextJs setup, what is the idiomatic way to share zod schemas between frontend and backev10 Migration interop, router doesnt have attributesHi, i've tried to migrate like stated in the docs, these are my routers. Question: Shouldn't appRoutRecommended file structure for next.js?Hey all - using tRPC heavily with next.js and it's great. Our main `[trpc].ts` file is getting huge Unhandled Runtime ErrorTRPCClientErrorCall Stack Function.from node_modules\@trpc\client\dist\TRPCClientError-09b8a26b.esm.js (57:0) transSharing middleware between TRPC serversWe currently have *microservices* REST API's on Cloudflare Workers and I'm thinking about moving thiIs `trpc.withTRPC` for Next supposed to work with pages or only `_app`?I'd love to only have TRPC mount on certain pages of my Next.js app. Is this currently supported?Are there any example of subscriptions working with react native ?queries and mutations are working pretty well with react native, I'm unable however to get subscriptRecommended way to prefetch client-sideIn react-query, you can do ``` queryClient.prefetchQuery(['todos', input], queryFn) ``` In trpc, IRevalidate API route from procedureHi, is there a way to revalidate a statically generated page from a trpc procedure? https://nextjs.Modifying payload client-side before cachingSay I have a payload that includes something like `category_id` in each of the items returned e.g.: Response headersIs it possible to modify the response headers from server to client?API Response caching not working on vercel ⁉I've followed the instructions in https://trpc.io/docs/v9/caching for API Response caching and it's when throwing a TRPCError, is there a way to include an internal error code ?for the given screenshot, if such error happens I wanna prompt the user to login or something.extra json property added after data when consuming a query hook.I have this issue where when consuming a RQ hook there is an extra `json` object that I have to use