繁体   English   中英

查找定义时,将另一个tsconfig.json文件添加到项目会混淆tsc

[英]Adding another tsconfig.json file to project confuses tsc when finding definitions

我有一个使用typescript的应用程序的文件结构,看起来与此类似。

./
./tsconfig.json
      /typings   /* typescript d.ts from typings */
      /src
      /sites
            /wiki
                  /scripts
                        /typescript-file.ts
                        /typescript-file.ts

而且效果很好。 但我遇到一种情况,我想在/wiki/目录中添加一个新的tsconfig.json ,以更改其在项目那部分中的行为方式。

乍一看似乎不错,但是每当我尝试在该目录上运行tsc时,我都会收到一条通知,通知它无法在/typings/目录中找到打字稿定义-这是一个更高的级别。

有什么我可以做的事情,不需要我将打字目录克隆到较低级别的文件夹中吗?

根级别tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "experimentalDecorators": true,
    "stripInternal": true,
    "noImplicitAny": false,
    "removeComments": false,
    "sourceMap": false,
    "target": "es5",
    "module": "commonjs",
    "allowSyntheticDefaultImports": true,
    "noEmitOnError": false,
    "moduleResolution": "node",
    "pretty": true,
    "declaration": false
  },
  "exclude": [
    "node_modules",
    "bower_components",
  ]
}

更高级别的tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "amd",
  }
}

有几点想法。

一个,您是否反对引入files属性? 我有一个tsconfig,具有以下文件属性:

"files": [
    "typings/tsd.d.ts",
    "src/main.ts",
    ...
]

src / main.ts导入的所有内容仍会编译。 您只需要指定导入图的入口点即可,这对我来说已经足够好了。

另一个更具争议的选项可能是通过符号链接将类型目录引入wiki目录,而不是手动复制它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM