Clarify that @trpc/server is needed as a dependency in the client
See original GitHub issueThis is not really a bug, but I thought it would help others if this is made a bit more clear. 🙂
We have a monorepo, in which I installed @trpc/client
and @trpc/server
in different packages.
However, I did not add @trpc/server
to the client.
Because of how the packages are (not) hoisted, this resulted in the client not being able to infer the types correctly and using any
as output without errors.
The reason is that @trpc/client
needs the server package to be available. But Typescript did not complain, due to the skipLibCheck option, I guess.
Ways to improve this
-
This should have resulted in an error ideally.
-
At least, the instructions on the website could instruct to install
@trpc/server
as a devDependency in the client. -
Another idea would be to have
@trpc/core
, which is maybe more intuitive than having@trpc/server
as a dependency in the client?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
It probably did, but it is a large project full of many other peerDependency warnings so I missed it. 😨
True, if both
@trpc/client
and@trpc/server
are installed on the same package, as in the examples, it is true that then we rely on the package manager to hoist them / deduplicate.Although, that already happens in my setup unfortunately, as the client needs
@trpc/server
, I have two copies of it. Depending on the package manager, that might or might not be hoisted.In my case, it is not, so I do have two copies of
@trpc/server
. It seems fine because it’s used for the types and they are version.