我们正在使用
Typescript
,
Prisma
和
TRPC
在两个需要相互通信的NodeJS服务中。这两个服务都有自己的数据库,因此在中生成的Prisma客户端
node_modules
不同文件夹之间不同。文件夹结构设置如下:
.
âââ service_1/
â âââ tsconfig.json
â âââ package.json
â âââ ...rest of project
âââ service_2/
âââ tsconfig.json
âââ package.json
âââ ...rest of project
因为我们使用TRPC,
service_1
直接从导入类型
service_2
如以下示例:
import type { AppRouter } from '../../../../service_2/src/routers/index'
这在VSCode中运行良好,但我们希望将类型检查作为CI操作
服务_1
,但正在运行
tsc -p ./tsconfig.json --noEmit
在的根
服务_1
显示了许多类似的错误:
../service_2/src/services/dog.ts:53:10 - error TS2339: Property 'dog' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
53 prisma.dog.findMany({
我们推测这是由Typescript使用生成的
@prisma/client
来自的程序包
服务_1
文件夹,即使在打字检查时
服务_2
,但我们已经尝试更改了
tsconfig.json
但无济于事。
我们的电流
tsconfig.json
在里面
服务_1
看起来是这样的:
{
"compilerOptions": {
"jsx": "react-jsx",
"strict": true,
"paths": {
"/*": ["./*"]
},
"baseUrl": "./",
"noEmit": true,
"esModuleInterop": true
},
"exclude": [
"**/node_modules/*",
"**/dist/*",
"**/.git/*",
],
}
我们尝试过的一些选项包括:
-
背景
rootDir
到
./
-
背景
根目录
到
../
-
背景
rootDirs
到
["./", "../service_2"]
-
正在添加
@ts-ignore
或
@ts-nocheck
高于类型导入
-
正在添加
服务_2
到
exclude
选项
有没有一种方法可以通过单独的
节点模块
一个从另一个进口?