[英]How to exclude files from being processed by tsc?
How do you stop tsc
from processing a Javascript file required by another?你如何阻止tsc
处理另一个需要的 Javascript 文件?
I want to run full checks on my main index.js
, but it requires()
a generated.js
Javascript file created by emcc
, which is perfectly fine, but doesn't pass a lot of tsc
's checks.我想对我的主index.js
运行全面检查,但它requires()
一个由emcc
创建的generated.js
Javascript 文件,这很好,但没有通过很多tsc
的检查。
I tried adding the file to my exclude list in my tsconfig.json
, like:我尝试将文件添加到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"
]
}
but that had no effect.但这没有任何效果。 When I run tsc --build tsconfig.json
I get a tone of errors from generated.js
.当我运行tsc --build tsconfig.json
时,我从generated.js
中得到了一个错误的基调。
The tsconfig.json
file looks for typescript files by default, while you are providing it .js
files.默认情况下, tsconfig.json
文件会查找 typescript 文件,而您提供的是.js
文件。 you can change the file extensions from .js
to .ts
to let typescript look after them.您可以将文件扩展名从.js
更改为.ts
以让 typescript 照顾它们。 so your tsconfig.json
file may end up looking like this:所以你的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.