3

I am trying to convert an ASP.NET Core app to VS 2017. Unfortunately, I'm unable to compile the site since I continually receive TypeScript errors. I'd rather VS not even touch my TypeScript since I'm using Webpack to do the actual building and bundling.

The site has an Angular 2 app in it, including some tests. Here's a sample error:

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

My app/tsconfig.json file looks like this:

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

Is there a way to tell VS to completely ignore my TypeScript when building? I don't know why it is even looking at these files.

Brian Vallelunga
  • 9,869
  • 15
  • 60
  • 87
  • It is possible your Visual Studio is using older version of TypeScript compiler. Can you confirm it is actually using the latest TypeScript? – Rosdi Kasim Apr 04 '17 at 15:00
  • I don't think I have a choice with 2017, do I? There's no newer version I can install. It's using 2.1 as far as I know, which is what came with 2017. – Brian Vallelunga Apr 04 '17 at 20:19
  • My `tsconfig.json` file location is one level higher than yours... and it has this `"baseUrl": "src",` and I dont even have `"exclude"` setting. – Rosdi Kasim Apr 05 '17 at 02:27
  • Not sure if this help, maybe worth trying: https://developercommunity.visualstudio.com/answers/11741/view.html – Rosdi Kasim Apr 05 '17 at 02:28
  • @RosdiKasim That link 404s for me. – Brian Vallelunga Apr 06 '17 at 14:58
  • Try opening a fresh Angular 4 project with that Visual Studio and see if you are having the same problem so that you know whether it is project specific or not. If not, you can always try this: http://stackoverflow.com/a/19460071/193634 You will have to reconfigure your VS though. – Rosdi Kasim Apr 07 '17 at 01:05

1 Answers1

9

If you do not want VS 2017 to compile your Typescript for you, please see the following documentation from TypeScript Handbook on how to disable compilation in 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.

joakimriedel
  • 1,801
  • 12
  • 27