Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript 0.9.1.1 Not Always Compiling On Save

Tags:

typescript

using VS 2012 Update 3, TSC 0.9.1.1., and the latest version of Web Essentials (although this has been a problem since Web Essentials removed support for TypeScript).

Very often TypeScript will not compile on save. I've had to resort to having the .js file open at the same time, and hope that I get the message about a file changing. But then all of a sudden it will stop building, and thus the file doesn't get changed and I don't see the message.

Sometimes it appears to be a problem with erroneous errors that TypeScript is generating, which I know they are because usually removing a ";" and adding it back will usually make it re-think it's error and remove it. The error doesn't even have to be on that file, and fixing the error never fixes the save & compile "feature".

The only "fix" I have found is to close the .ts file, and .js file (.js file is important). Then open the .ts, wait for it to fully load, and then load the .js file, in that order, or it will never work (you don't have to open the .js file, but if you open it first it won't work).

I've tried restarting (VS and Win 7) and that will fix it for awhile, but eventually and again often it will stop working.

This is very annoying as I'm writing TypeScript the vast majority of the day.

like image 325
Kevin S Avatar asked Oct 15 '13 01:10

Kevin S


2 Answers

I authored grunt-ts to do our typescript compilation which works reliably every time : https://npmjs.org/package/grunt-ts

Check out the video tutorial : http://youtu.be/Km0DpfX5ZxM

like image 121
basarat Avatar answered Sep 29 '22 09:09

basarat


I find that doing a project compile (cs/vb) is required to generate the initial .js file. After that, the typescript compile on save works properly.

like image 45
Alex Dresko Avatar answered Sep 29 '22 11:09

Alex Dresko