Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Typescript compiler from generating JS and JS.MAP files in Visual Studio 2017?

I have a few typescript files for my app myapp in my Visual Studio 2017 ASP.NET project. I use a gulp task to generate the JS files, so I don't want the build or language service creating these JS and JS.MAP files.

This is how my TSCONFIG file look like:

{
  "compileOnSave": false,
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "module": "system",
    "types": [ "" ],
    "lib": [
      "es6",
      "dom"
    ]
  },
  "include": [
    "./myapp/**/*"
  ]
}

I tried the following:

  1. I added the myapp to the exclude section of the tsconfig.js. Both the js and js.map are not generated at that time if I close Visual Studio and open again. But I see a lot of compilation errors.

  2. I added <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> to the .csproj file. I closed VS 2017, opened again and did a build. I see the JS and JS.MAP files.

  3. I changed the BuildAction property to none, but still see the JS and JS.MAP files

enter image description here

What should I do so the syntax check of the TS file will work but does not generate any JS and JS.MAP files?

like image 373
wonderful world Avatar asked Aug 28 '17 12:08

wonderful world


2 Answers

If Visual Studio seems to be ignoring the noemit option in the tsconfig file, edit your project file. In the project file, go to the <PropertyGroup> that contains the rest of the TypeScript options and add <TypeScriptNoEmit>True</TypeScriptNoEmit> between that PropertyGroup's open and closing tags.

like image 170
Miikee Avatar answered Sep 20 '22 21:09

Miikee


Try add "noEmit": true in your tsconfig. It should prevent the .js .js.map from generating.

like image 26
Nathaniel Avatar answered Sep 19 '22 21:09

Nathaniel