Typescript optimisation

I'm trying to optimise the generated types from the router, as I see that lots of types for context are being typed over and over instead of being made once and re-used, which influences total type to infer alot. I managed to cut my total router dts from 1.5mb -> 840kb already (1.5mb being the tsc limit) But I think we can do better See attached image, the ctx object and transformers is present on every router
No description
LL
Laurens Lavaert37d ago
I know that in v11 there is work done for this aswell, so may be overlapping but was wondering if anyone else had tried to optimise the _config types before Additionally _ctx_out could benefit from type reuse aswell, as I think if I could hard-type the output of my modified procedures where context changes, that it would speed up a lot @Alex / KATT 🐱 I know you've also been compiling types lately, perhaps you've also encountered the 1.5mb limit like I have 🙈 So I managed to get the ctx to match my predefined type by doing explicitly typing the returns of all the createCtx functions
LL
Laurens Lavaert37d ago
☝️
No description
LL
Laurens Lavaert37d ago
So down to 754.55 KB 50% improvement 👀
LL
Laurens Lavaert37d ago
Currently trying to hard-type procedure builders, however I'm a bit off on how it should be
No description
AK
Alex / KATT 🐱37d ago
have you upgraded to v11? we've removed the ctx and stuff on the resolver procedures
LL
Laurens Lavaert37d ago
Is it ready to be used in prd tho :p
AK
Alex / KATT 🐱37d ago
yes
LL
Laurens Lavaert37d ago
Ait imma check out the resolved types
AK
Alex / KATT 🐱37d ago
No description
LL
Laurens Lavaert37d ago
DTS src/server/api/root/index.d.mts 140.75 KB omfg
AK
Alex / KATT 🐱37d ago
lgtm 😄
LL
Laurens Lavaert37d ago
Might no longer have to compile my types gahd damn
AK
Alex / KATT 🐱37d ago
you probably want to do that still do you still declarationMap? CMD+clicking should work if you do
LL
Laurens Lavaert37d ago
Hmm now I'm keen to set it up Because I was so close to the limit of 1.5mb all the time I put it off cuz I was gonne split the routers in seperate packages to each have seperate compilation But now I got a lot more headroom bruhhh why did react query change isLoading to something else
LL
Laurens Lavaert37d ago
AK
Alex / KATT 🐱37d ago
i know, i tried to make the case that it was annoying it's mostly search and replace tho
LL
Laurens Lavaert37d ago
True true Do you just compile the types cuz I esbuild the whole router and import that one xd
More Posts
Is it possible to change how TRPC maps routers to URL paths?Hello there, in my current project I would like to map merged routers to subpaths in the url. For eCreate user on the function mutate, with TRPC and PayloadHi everyone, I have faced issues with create user on the function mutate, with TRPC, I cant trace anHow to not prefetch on getServerSideProps if it's already fetched?I have a `getServerSideProps` that utilizes `createServerSideHelpers`, and when I access a page I prReturn undefined if param is not thereIn this code cityById could be undefined and I want that this checks this and then weatherData gets useQuery caching dataHello, I have a problem. I want to do such a thing as checking for the existence of a nickname in thError using createTRPCQueryUtilsHere is my code. ```tsx const trpc = createTRPCReact<TRPCRouter>(); const queryClient = new QueryClWhy do we pass the database client in the contextHey there 👋 In the examples and in T3app we pass the db client in the trpc context ``` export asSubscriptions between different servicesHow do you make subscriptions to work between different services? For example if we have two differeServing files with TRPC and ExpressHi! Is there any way to serve files using express while using trpc typed way? As in using ```ts TRPC useQuery() in NextJS full stack with TypeScriptHi, I'm relatively new to web dev in general and just trying to get to grips with using TRPC so pleaNot getting "User" type on context.I am creating a few "custom" procedures that uses middleware to authenticate a user, like this: ```tType error when creating a server-side context 🤔I am trying to set up my context for TRPC server, and I get the attached error. I am using TRPC v10The inferred type of 'trpc' cannot be named without a referenceI'm getting the same error as this post: https://discord.com/channels/867764511159091230/11707368517how to solve thismy query is declared right when i go to this url localhost:3000/api/trpc/gethello i get my output bis it possible to set a response middleware on Vanilla trpc client?I have a vue app and I want to set a middleware on the response, whenever I get a response if I findBug: Setting up cookies not woring when using .input in nextjsHey guys I am trying to set up a cookie with nextjs 14 and trpc. However my cookie is only being setWhat's the best practices around tRPC to negotiate API-versions?In my example I'm thinking about having a native app as a tRPC client and a locally deployed docker Is there a way to pass context or cookies to the client provider?```typescript export default function APIProvider({ children, }: { children: React.ReactNode; })Is there a way to pass context or cookies to the client provider?```typescript export default function APIProvider({ children, }: { children: React.ReactNode; })Why deprecate experimental_standaloneMiddleware?I am reading https://trpc.io/docs/server/middlewares#experimental-standalone-middlewares, but it's s