Roaders
Roaders

Reputation: 4545

How do I make Visual Studio overwrite my JS file when doing a Typescript build

I have Visual Studio and am using it to build my typescript project. I have one build.ts file that links to all my other TS files and they are all compiled to one app.js file (with an associated map file).

The build apparently works fine but if the js file is already there it is not updated. If I delete the js file and build it is created no problem, it is only a problem if the js file is already there. The js file is NOT read only.

I have solved this by adding a call to tsc in my prebuild event command line - this works fine. This does not seem ideal though as I have to have my build configuration setup in 2 different places. When I moved to Typescript 1.5 I got all sorts of odd errors as VS was on 1.5 but my build command was on 1.4.

I can live with the workaround but it seems like a fairly major failing by VS that it doesn't actually update my compiled output.

Upvotes: 1

Views: 1938

Answers (2)

Elisabeth
Elisabeth

Reputation: 21226

var del = require(gulp-delete);

Just run a gulp del(PathToDelete) before you compile!

Upvotes: 0

Lukkha Coder
Lukkha Coder

Reputation: 4460

Often times this will happen when there is a compile time error in Typescript and the following options are checked:

  1. Compile on save: This will cause the build to be marked as succeeded even when there are compile error in Typescript.
  2. Do not emit outputs if an error are reported: This along with the previous option will make it seem that the build succeeds but the js file is not updated.

enter image description here

Upvotes: 2

Related Questions