This project is read-only.

Suggestions for .NET MVC app setup for using typescript with existing JS.

Topics: General
Sep 12, 2013 at 10:38 AM
Or "The story of how we upgraded from 0.8 and then nothing worked"

I am posting this for two reasons. Firstly, to document some of the types of issues we've faced with the Typescript plugin ( because it seems a few other people are having similar issues. Secondly, it's to ask for advice about project setup, hoping some other people have moved past these issues already.

Some prerequisite facts: We've got VS2012, the latest typescript plugin, WebEssentials is updated to 3.0 to ensure there are no conflicts.

Our overall business scenario is that we have been maintaining a web application for a long time and we wanted to start using typescript for new pages.

So the directory layout as per the usual setup for an MVC app. There's a "scripts" directory with a bunch of third party scripts in it and a subdirectory with our JS code in it (usually at least one per web page). We added another subdirectory within the first one where we put all our typescript files.

Initially, we were using WebEssentials to automatically compile the typescript files in the MVC project. The output files would be added automatically and this worked well with our existing JS files.

Updating - And what doesn't work
Here is my experience with updating. The process was to update WebEssentials (to get rid of any chance of conflict), install the VS Typescript plugin, check that something appeared to be happening when we saved or compiled a TS file, then do some testing on our web pages to make sure things still seemed to be working. This all went quite well.

However when I began to work with the Typescript files, I found a few problems. Some of them would not update the JS file on save. To check this, I removed the JS file and found it would not be generated by save or compiling in VS. I followed the steps at the compile-and-save wiki and made sure that the BuildAction was set to TypeScriptCompile and this made no difference. However some files don't have this issue, although at times the response time between saving and seeing the JS file get changed is very slow.

Because we had previously used other tools and so on, the JS files generated from the TSC compile were included in the project. This seemed to have some affect on whether or not the compile-on-save feature would work. That is, it would work at first, but if we removed the JS file from the project, it would stop working. Again, this behaviour hasn't been consistent for all files, just some.

I have also tried adding a new TS file into the same folder by using the context menu in solution explorer. This appears to create file which works, although again performance does seem quite slow.

I think I'm doing this wrong
Currently the setup isn't working since we can't rely on VS compiling the TS files. We have about 25 files or so, so it's not huge and I am wondering if it would be best to set things up differently if it means I can get more robust behaviour from VS or set things up so that it will be easy to use command line tools.

If you have a suggestion about how we could set things up, please let me know.
Sep 12, 2013 at 8:04 PM
check the solution I found to this in the last post of the thread below and see if it works for you.