繁体   English   中英

如何排除文件被 tsc 处理?

[英]How to exclude files from being processed by tsc?

你如何阻止tsc处理另一个需要的 Javascript 文件?

我想对我的主index.js运行全面检查,但它requires()一个由emcc创建的generated.js Javascript 文件,这很好,但没有通过很多tsc的检查。

我尝试将文件添加到tsconfig.json中的排除列表中,例如:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": [
        "dom",
        "webworker"
    ],
    "allowJs": true,
    "checkJs": true,
    "outDir": "./dist",
    "noImplicitAny": false,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "index.js"
  ],
  "exclude": [
    "generated.js"
  ]
}

但这没有任何效果。 当我运行tsc --build tsconfig.json时,我从generated.js中得到了一个错误的基调。

默认情况下, tsconfig.json文件会查找 typescript 文件,而您提供的是.js文件。 您可以将文件扩展名从.js更改为.ts以让 typescript 照顾它们。 所以你的tsconfig.json文件可能最终看起来像这样:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "lib": [
        "dom",
        "webworker"
    ],
    "allowJs": true,
    "checkJs": true,
    "outDir": "./dist",
    "noImplicitAny": false,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "index.ts"
  ],
  "exclude": [
    "node_modules",
    "generated.ts"
  ]
}

暂无
暂无

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

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