tRPC AppRouter is defined as "any" on import with Turborepo
Asked Answered
R

0

9

I am currently using a monorepo with Turborepo to store all my microservices code in a single repository, each with a package.json and a tsconfig.json, all of them written in nodejs.

in each tsconfig.json, the config is identical

{
  "extends": "@tsconfig/node18-strictest-esm",
  "compilerOptions": {
    "outDir": "build",
    "baseUrl": ".",
    "paths": {
      "@/*": ["./*"],
      "@folder-a/*": ["./folder-a/*"], // masked
      "@folder-b/*": ["folder-b/*"] // masked
    }
  },
  "exclude": ["node_modules", "build"]
}

I have one service A as a tRPC server, and one service B as a tRPC client.

When I imported the type definition of AppRouter from A to B, the type definition becomes any in B when it is properly typed in A.

Reference pic here.

I researched about it and found similar issue, and it seems like path alias may cause this issue.

Is there any solution/alternate cause to this

Rb answered 30/12, 2022 at 4:58 Comment(1)
Btw to anyone visiting this question, as no one has an apparent fix for this yet, I have since switched to using Nx as the monorepo and it's working fine for me.Rb

© 2022 - 2024 — McMap. All rights reserved.