Losing the type between the client and server
Hello everyone, I am new to tRPC and the magic of types in typescript so I am looking for ideas as to what is happening, the client is receiving any type instead of a string
11 Replies
I doubt this is a bug, but I have no idea where to go for.
This is on the client
And this is on the server
Do you have strict mode? Are you using any data transformers?
Hey @julius, I am using strict mode and I am using superjson. I am currently debugging on a reproducable repo first, but with a stripped down setup the types are working, so I am super confused at the moment
Do you maybe have any pointers at the top of your head that can break types between projects. I basically have a monorepo
I just import the type from
../apps/backend/src/trpc.ts
I'll keep debugging and close this if I find the culpritNot really, is the repo public?
I have a minimal repository that closely mimics my real project which is unfortunately commercial and private, but I cannot for the life of me replicate the issue I am having in the real project @julius
For example
In my main project it has
any
types like displayed bellow but in my demo project it correctly has the uid
and email
as strings
So I thought that the types might be incorrect all together but if I do
It gets inferred to
The type is correct on the server but gets inferred to any in the client
But as you can see the types do get across
Just some are any
I have absolutely no clue as to what is happening
Also the inferred type of my mutation has the same issue
But on the server the types are all okay
might be invalid tsconfig? or do you use the same in the repro?
Both are the same, strict mode is on
But the types are getting through to the client, just for some reason some types are lost and inferred to any
Thats why I am super confused
yea if you cant provide a repro i really cant help you since ive never seen this before
Yeah I'll try to get it reproduced and push it to gh
Hey @julius, tried my best to create a simple reproducible repository that reflects my issue. I added a readme that clarifies the issue further, here is the repo
https://github.com/Nikola-Milovic/monorepo-trpc-issue
I know this is a tall ask to check out but thank you nonetheless
GitHub
GitHub - Nikola-Milovic/monorepo-trpc-issue
Contribute to Nikola-Milovic/monorepo-trpc-issue development by creating an account on GitHub.
Inside
packages/config
are the tsconfig
files and they all inherit from the base.json
which defines the strict: true