2

I'm trying to use TypeScript in my MVC4 application.

I add a TypeScript file to the Scripts folder y my app but Visual Studio 2012 doesn't generate the .js and .map files. It seems that ignore this file.

Using previous versions of WebEssentials and TypeScript my TypeScript files were compiled when I saved the .ts file, and .js and .map files where automatically generated.

Now with the latest version of WebEssentials and TypeScript I can't do the same.

What's new? What do I have to do to make it work?

ZygD
  • 22,092
  • 39
  • 79
  • 102
Javier Ros
  • 3,511
  • 2
  • 21
  • 41
  • Possible duplicate of [Using TypeScript in an existing Visual Studio Web Site project](http://stackoverflow.com/questions/12867390/using-typescript-in-an-existing-visual-studio-web-site-project) - and I have kept the answer on that question up to date. – Fenton Dec 05 '13 at 15:54

2 Answers2

6

I have found the solution comparing a TypeScript project file with a MVC project file.

In my MVC project file I have added this:

<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>

to the "Debug" and "Release" property groups, but it didn't work but I have seen this line at the end of my TypeScript project:

<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />

I have append this line to my MVC project and "voila!" compile on save works fine now.

Thanks

Javier Ros
  • 3,511
  • 2
  • 21
  • 41
0

Webessentials dropped support for TypeScript starting in V3, since it would be taken up by the VS team. And as map features are not implemented, they will not work at the moment. Compile on save should work though

basarat
  • 261,912
  • 58
  • 460
  • 511
  • Thanks. Compile on save only works if I create a TypeScriptHtml Project, but don't work in a MVC4 project ... What's happening? – Javier Ros Sep 20 '13 at 06:21
  • 1
    There is a really good answer on the subject : http://stackoverflow.com/a/16660417/390330 – basarat Sep 20 '13 at 06:37