我已经开始将Angular 2集成到现有项目中。作为我的编辑器,我使用Visual Studio 2015社区版。我将我的Visual Studio更新到最新版本(更新3),以解决intellisense的问题并更新到最新的typescript插件版本(2.0.6)。在我更新之前,项目编译并运行良好。在更新之后,我从node_modules中的不同文件中获取了多个错误。自更新以来我没有更改任何代码。我在我的主tsconfig.json文件中排除了node_modules,但显然Visual Studio仍然尝试在那里编译文件。Visual Studio/Angular 2 - 更新后未排除node_modules文件夹
我tsconfig.json看起来是这样的:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true
},
"types": [
"core-js",
"node"
],
"exclude": [
"node_modules"
],
"compileOnSave": true
}
我已经更新了我的csproj文件与打字稿版本号:
<TypeScriptToolsVersion>2.0.6</TypeScriptToolsVersion>
我也有以下的信息在我的csproj文件:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<TypeScriptTarget>Unknown</TypeScriptTarget>
<TypeScriptJSXEmit>-1</TypeScriptJSXEmit>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>True</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
<TypeScriptModuleResolution>node</TypeScriptModuleResolution>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>False</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />
<TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
</PropertyGroup>
我已经更新了视觉工作室的构建输出到“详细”水平和它看起来像Visual Studio试图编译它发现在我的node_modules文件夹中的每个tsconfig文件时,它会得到一个错误之前:
1>Target "CompileTypeScriptWithTSConfig" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets" from project "C:\Projects\web\src\Web.csproj" (target "Compile" depends on it):
1>Task "VsTsc"
1> C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --project "C:\Projects\web\src\FrontEnd\node_modules\browser-sync\node_modules\rx\ts\tsconfig.json" --listEmittedFiles
1>C:\Projects\web\src\Frontend\node_modules\browser-sync\node_modules\rx\ts\core\linq\observable\pairs.ts(28,5): error TS2322: Build:Type 'Observable<[string, {}]>' is not assignable to type 'Observable<[number, string]>'.
1> Unknown output: Type '[string, {}]' is not assignable to type '[number, string]'.
1> Unknown output: Type 'string' is not assignable to type 'number'.
1>C:\Projects\web\src\Frontend\node_modules\browser-sync\node_modules\rx\ts\core\linq\observable\pairs.ts(29,5): error TS2322: Build:Type 'Observable<[string, {}]>' is not assignable to type 'Observable<[number, string]>'.
1> Unknown output: Type '[string, {}]' is not assignable to type '[number, string]'.
1> Unknown output: Type 'string' is not assignable to type 'number'.
1>C:\Projects\web\src\Frontend\node_modules\browser-sync\node_modules\rx\ts\core\notification.ts(83,34): error TS7024: Build:Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
1> The command exited with code 2.
任何帮助,将不胜感激
由于错误都发生在节点模块中,您是否尝试过运行npm install? – Bean0341