hagner
hagner

Reputation: 1050

Visual Studio/Angular 2 - node_modules folder not excluded after update

I have a started to integrate Angular 2 into an existing project. As my editor I use Visual Studio 2015 community edition. I updated my Visual Studio to latest version (update 3) to solve a problem with intellisense and updated to latest typescript plugin version (2.0.6). Before my update, the project compiled and ran fine. After my update I get multiple errors from different files in node_modules. I have not changed any code since the update. I have excluded node_modules in my main tsconfig.json file but apparently visual studio still tries to compile files there.

My tsconfig.json looks like this:

{
  "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
}

I have updated my csproj file with the typescript version number:

<TypeScriptToolsVersion>2.0.6</TypeScriptToolsVersion>

I also have the following information in my csproj file:

<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>

I have updated the output on build in visual studio to "Detailed" level and it look like Visual studio tries to compile for every tsconfig file it finds in my node_modules folder before it gets an error:

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.

Any help would be appreciated

Upvotes: 0

Views: 1174

Answers (1)

John Lee
John Lee

Reputation: 1387

I know this is old but I came across this as I was looking up something else and since it wasnt answered -

In Visual Studio, you need to exclude the node_modules folder from the VS Project, not the tsconfig file. You should not be able to see the node_modules folder in your solution explorer (unless you have the view all files icon selected).

Upvotes: 1

Related Questions