Visual Studio 2017 TypeScript 编译错误
Visual Studio 2017 TypeScript compilation errors
我正在尝试将 ASP.NET 核心应用程序转换为 VS 2017。不幸的是,我无法编译该网站,因为我不断收到 TypeScript 错误。我宁愿 VS 甚至不碰我的 TypeScript,因为我正在使用 Webpack 进行实际的构建和捆绑。
该网站有一个 Angular 2 应用程序,包括一些测试。这是一个示例错误:
Error TS2665 Build:Invalid module name in augmentation. Module
'angular-mocks/ngMock' resolves to an untyped module at
'D:/myapp/source/MySite/node_modules/angular-mocks/ngMock.js', which
cannot be augmented.
MySite D:\myapp\source\MySite\node_modules\@types\angularjs\angular-mocks.d.ts 8
我的 app/tsconfig.json 文件如下所示:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"experimentalDecorators": false,
"sourceMap": false,
"module": "commonjs",
"moduleResolution": "node",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
},
"exclude": [
"../node_modules",
"../wwwroot"
],
"compileOnSave": false
}
有没有办法告诉 VS 在构建时完全忽略我的 TypeScript?我不知道它为什么还要看这些文件。
如果您不希望 VS 2017 为您编译 Typescript,请参阅 TypeScript Handbook 中有关如何在 MSBuild 中禁用编译的以下文档。
TypeScriptCompileBlocked
If you are using a different build tool to build your project (e.g.
gulp, grunt , etc.) and VS for the development and debugging
experience, set
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
in your
project. This should give you all the editing support, but not the
build when you hit F5.
我正在尝试将 ASP.NET 核心应用程序转换为 VS 2017。不幸的是,我无法编译该网站,因为我不断收到 TypeScript 错误。我宁愿 VS 甚至不碰我的 TypeScript,因为我正在使用 Webpack 进行实际的构建和捆绑。
该网站有一个 Angular 2 应用程序,包括一些测试。这是一个示例错误:
Error TS2665 Build:Invalid module name in augmentation. Module 'angular-mocks/ngMock' resolves to an untyped module at 'D:/myapp/source/MySite/node_modules/angular-mocks/ngMock.js', which cannot be augmented. MySite D:\myapp\source\MySite\node_modules\@types\angularjs\angular-mocks.d.ts 8
我的 app/tsconfig.json 文件如下所示:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"experimentalDecorators": false,
"sourceMap": false,
"module": "commonjs",
"moduleResolution": "node",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
},
"exclude": [
"../node_modules",
"../wwwroot"
],
"compileOnSave": false
}
有没有办法告诉 VS 在构建时完全忽略我的 TypeScript?我不知道它为什么还要看这些文件。
如果您不希望 VS 2017 为您编译 Typescript,请参阅 TypeScript Handbook 中有关如何在 MSBuild 中禁用编译的以下文档。
TypeScriptCompileBlocked
If you are using a different build tool to build your project (e.g. gulp, grunt , etc.) and VS for the development and debugging experience, set
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
in your project. This should give you all the editing support, but not the build when you hit F5.