typescript 排除 tsconfig.json 中的子目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35647862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
exclude subdirectories in tsconfig.json
提问by DNRN
I have installed TypeScript 1.8.2, and using Visual Studio 2015. I have a simple project where I have problems excluding folders from the tsconfig.json file. The problem is I would like to exclude the file typings/browser.d.ts and the folder typings/browser. But this is not the case?
我已经安装了 TypeScript 1.8.2,并使用了 Visual Studio 2015。我有一个简单的项目,我在从 tsconfig.json 文件中排除文件夹时遇到了问题。问题是我想排除文件typings/browser.d.ts 和文件夹typings/browser。但这种情况并非如此?
I have no problems excluding a subfolder, but not a sub-subfolder?
我没有排除子文件夹的问题,但不是子文件夹?
[NOTE] I just realized the problem is only when I build from Visual Studio! If i build with tsc from the command line, there's no problem. Could I have another version of TypeScript in Visual Studio? How can I check this?
[注意] 我刚刚意识到只有当我从 Visual Studio 构建时才会出现问题!如果我从命令行使用 tsc 构建,则没有问题。我可以在 Visual Studio 中使用另一个版本的 TypeScript 吗?我该如何检查?
This is my tsconfig.json:
这是我的 tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"public",
"typings/browser",
"typings/browser.d.ts"
]
}
I have a bigger project, where I use jspm and need to exclude the jspm package folder, which is located as a subfolder to public.
我有一个更大的项目,我在其中使用 jspm 并需要排除 jspm 包文件夹,该文件夹位于 public 的子文件夹中。
采纳答案by SourceSimian
I just installed and tested the latest version of TypeScript for Visual Studio 2015 (1.8.6 at the moment), and I can confirm that this problem has been fixed in the latest release.
我刚刚为 Visual Studio 2015 安装并测试了最新版本的 TypeScript(目前为 1.8.6),我可以确认这个问题已在最新版本中得到修复。
https://www.microsoft.com/en-us/download/details.aspx?id=48593
https://www.microsoft.com/en-us/download/details.aspx?id=48593
[Edit] Be sure to also do an npm update -g typescript
[编辑] 一定还要做一个 npm update -g typescript
回答by Amid
Try with:
尝试:
"exclude": [
"node_modules",
"public",
"typings/browser.d.ts",
"typings/browser/**"
]
回答by Vinod Loha
Looks like this is a problem with typescript being unable to exclude paths/patterns that belong to deeper dir structure. Its still a problem with "typescript@^3.4.5".
看起来这是打字稿无法排除属于更深层目录结构的路径/模式的问题。它仍然是“typescript@^3.4.5”的问题。
To fix this I started cleaning my Dist dir with "rimraf dist" before every test run.
为了解决这个问题,我开始在每次测试运行之前用“rimraf dist”清理我的 Dist 目录。
"test:unit": "npm run clean && stencil test --spec --snapshot",
I know its a hack, but works.
我知道它是一个黑客,但有效。