我正在尝试将 Visual Studio 用作我的 IDE,以使用 Angular 2 开发 ASP.NET MVC 5 SPA。
当我尝试构建项目时出现问题。它在 *.d.ts
文件中给了我很多错误。
我使用 angular-cli
命令创建了项目:ng new project-name
这是解决方案资源管理器的样子:
如何消除这些错误?我在 Visual Studio Code 中使用 angular 2 没有遇到任何问题
更新:
根据您的回答,我在 tsconfig.json
文件中添加了以下内容,但似乎不起作用
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016"
]
},
"exclude": [
"./node_modules",
"**/*.spec.ts"
]
}
最佳答案
确保您使用的是适用于您的 Visual Studio 版本的最新 Typescript 工具。我的一位同事遇到了类似的问题,如果您已经在 tsconfig 中排除了 node_modules 文件夹,这可能就是问题所在。
对于 VS 2015: https://www.microsoft.com/en-us/download/details.aspx?id=48593
关于angular - 如何从 visual studio 2015 update 3 的构建中排除 node_module 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42714304/