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.

6
  • It is possible your Visual Studio is using older version of TypeScript compiler. Can you confirm it is actually using the latest TypeScript? Commented Apr 4, 2017 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. Commented Apr 4, 2017 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. Commented Apr 5, 2017 at 2:27
  • Not sure if this help, maybe worth trying: developercommunity.visualstudio.com/answers/11741/view.html Commented Apr 5, 2017 at 2:28
  • @RosdiKasim That link 404s for me. Commented Apr 6, 2017 at 14:58

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.