我已經開始將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