我试图让 Typescript 在编译时排除某些文件。但是,它似乎并不想排除它们。
这是我的 tsconfig.json
{
"ref": "master",
"path": "typings",
"compilerOptions": {
"module": "amd",
"target": "es5",
"declaration": true,
"sourceMap": true,
"outDir": "build/src"
},
"exclude": [
"node_modules",
"typings/global",
"typings/index.d.ts",
"./src/subClassA.ts"
],
"files": [
"./src/entry.ts"
]
}
它似乎排除了 node_modules 和 typings。但是编译后的代码,仍然包含 subClassA。
我原以为编译后的代码没有任何来自 subClassA 的代码,但它确实有。
最佳答案
来自documentation :
Any files that are referenced by files included via the "files" or "include" properties are also included. Similarly, if a file B.ts is referenced by another file A.ts, then B.ts cannot be excluded unless the referencing file A.ts is also specified in the "exclude" list.
如果您的./src/entry.ts
文件或./src/entry.ts
的任何依赖项使用./src/subClassA.ts
某处,则 ./src/subClassA.ts
不能被排除,除非 ./src/entry.ts
也被排除。
关于javascript - Typescript tsconfig 排除一些源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43538650/