Rick Strahl Rick Strahl - 2 months ago 23
TypeScript Question

ASP.NET Core Project: How to keep Typescript from Compiling

I'm trying to integrate an existing Angular 2 application into an existing ASP.NET Core project in Visual Studio. Both projects work independently, but when I try to compile the ASP.NET Core project in Visual Studio I get a bunch of typescript compilation errors related to files in the

node_modules
folder.

enter image description here

How do I:


  • Keep typescript from compiling at all

  • Keep the compiler from looking at anything in
    node_modules



I can get this to work by moving the
node_modules
folder out into the project root, but this would require completely rearranging the the original project dependencies and build files and I would prefer to avoid that.

Answer

-1-. You can disable typescript compiling by editing project file (.xproj). Add this block:

<PropertyGroup>
    <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>   

-2-. To keep the compiler from looking at anything in node_modules - use exclude in tsconfig:

"exclude":[
  "node_modules"
]

* Path to node_modules is relative to tsconfig.json

Comments