打字稿在错误的目录中输出定义

问题描述

是TypeScript的新手,我在编译项目时遇到了问题,该项目是使用yarn工作区的monorepo。

假设这是我的工作空间配置:

"workspaces": [
    "package1","common/*" // contains JavaScript packages (no ts here)
  ]

package1使用的是通用软件包。这是我的package1 / tsconfig.json:

"compilerOptions": {
  "module": "esnext","target": "es2017","esModuleInterop": true,"lib": ["es2019"],"skipLibCheck": true,"moduleResolution": "node","forceConsistentCasingInFileNames": true,"noImplicitReturns": true,"noImplicitThis": true,"noImplicitAny": true,"strictFunctionTypes": true,"strictnullchecks": true,"suppressImplicitAnyIndexErrors": false,"noUnusedLocals": false,"downlevelIteration": true,"resolveJsonModule": true,"sourceMap": true,"declaration": true,"baseUrl": ".","paths": {
    "common/*": ["../common/*"]
  },"composite": true,"rootDir": "src","outDir": "dist","declarationDir": "dist","allowJs": true,"isolatedModules": true
},"include": ["./src/**/*"],"exclude": ["node_modules","dist","../common/*"]

当我运行tsc时,打字稿是 common 中的通用d.ts文件,我该如何特别地告诉他将其放在package1 / dist / common / *中?

我也有一些错误

  • 文件'/common/lib1/index.js'不在'rootDir''/ package1'下。 “ rootDir”应包含所有源文件。 ts(6059)

  • 文件'/common/lib1/index.js'未在项目/package1/tsconfig.json'的文件列表中列出。项目必须列出所有文件或使用“包含”模式。 ts(6307)

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)