tRPCttRPC
Powered by
segment_treeS
tRPC•2y ago•
41 replies
segment_tree

The inferred type of 'trpc' cannot be named without a reference to '...'

I have a monorepo setup like this:

root
-tsconfig.json
-frontend
--tsconfig.json
-backend
--tsconfig.json

I added a reference in the client tsconfig:

  "references": [
    {
      "path": "../backend"
    }
  ],
  "references": [
    {
      "path": "../backend"
    }
  ],


I added
"composite": true
"composite": true
to my backend tsconfig.

In my root tsconfig, I have:

{
  "references": [
    {
      "path": "./backend"
    },
    {
      "path": "./frontend"
    }
  ],
  "files": [],
  "include": [],
  "exclude": ["**/node_modules"]
}
{
  "references": [
    {
      "path": "./backend"
    },
    {
      "path": "./frontend"
    }
  ],
  "files": [],
  "include": [],
  "exclude": ["**/node_modules"]
}


However, now in my client, when I create my trpc instance:

export const trpc = createTRPCReact<AppRouter>();
export const trpc = createTRPCReact<AppRouter>();


I get a bunch of typing errors:

The inferred type of 'trpc' cannot be named without a reference to '../../../backend/node_modules/.prisma/client'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'trpc' cannot be named without a reference to '../../../backend/node_modules/@types/express'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'trpc' cannot be named without a reference to '../../../backend/node_modules/.prisma/client'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'trpc' cannot be named without a reference to '../../../backend/node_modules/@types/express'. This is likely not portable. A type annotation is necessary.ts(2742)


Where is this coming from and how can I fix it?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

The inferred type of 'trpc' cannot be named without a reference
sh03Ssh03 / ❓-help
2y ago
The inferred type of 'trpc' cannot be named without a reference ...
jacobJjacob / ❓-help
3y ago
Type error: The inferred type of 'trpc' cannot be named without a reference....
j...Jj... / ❓-help
3y ago
The inferred type of 'trpc' cannot be named without a reference. A type annotation is necessary.
KrishnaKKrishna / ❓-help
3y ago