Monorepo with React Native + Next.js
See original GitHub issueHello 👋
We built a nextjs website with trpc and it has worked wonderful 🙌 Now we’re migrating the website to react-native and have setup a monorepo with yarn workspace
and lerna
to keep backend in nextjs, but have the frontend in react-native. To share code I’m extracting the trpc
code to a common
-package and get some error. It’s probably due to bad tsconfig (I’m not yet an ts-expert…).
This error occurs when building the nextjs project:
../common/utils/trpc-client.ts:14:14
Type error: Exported variable 'trpc' has or is using name 'UseTRPCInfiniteQueryOptions' from external module "mono/node_modules/@trpc/react/dist/declarations/src/createReactQueryHooks" but cannot be named.
12 | */
13 |
> 14 | export const trpc = createReactQueryHooks<AppRouter>();
| ^
15 |
16 | export const transformer = superjson;
17 |
error Command failed with exit code 1.
I don’t understand the errormessage. But if i go inte node_modules/@trpc/react/dist/declarations/createReactQueryHooks.d.ts
and export all interfaces (e.g the UseTRPCInfiniteQueryOptions
-interface) the error goes away.
My question is; Does anyone understand the error and know how I should config my tsconfig to solve this? Or, is this something that could be fixed by a version-update on trpc? 🙏
// Christopher
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top GitHub Comments
Would love having a chat with you about the setup, I’ll book a slot 🥳 I have a similar setup that you propose but with the packages
web
,app
, andcommon
. The common-package both contains the trpc routers, but also some react-code so that we in the future can share it with the web usingreact-native-web
. I’ll look into the repo for inspiration until our meeting.This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.