How to enable Typescript for existing project. (version

Topics: General
Apr 15, 2013 at 11:32 AM
Edited Apr 15, 2013 at 11:33 AM

What is the correct and best way that I enable Typescript (version for an existing project ?

I found different information about lines that needs to be added to the project file, but I think maybe some of the information is out of date.

Best regards,

Anders Both
Apr 15, 2013 at 2:03 PM
We're currently working on some features that should make it much easier to upgrade existing projects. For now, the best thing is to create a new project with TypeScript support using, edit the project and look for the lines that enable TypeScript, and then copy those into your existing project.

Some others who have done the upgrade my be able to tell you better, but these are some of the lines you're looking for:
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
  <Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
There's also an earlier section in the file that, I believe, gives you the nice tree view for your .ts files, showing the corresponding .js file as a child:
    <Content Include="app.css" />
    <Content Include="default.htm" />
    <Content Include="app.js">
    <TypeScriptCompile Include="app.ts" />
Apr 15, 2013 at 4:44 PM
Edited Apr 15, 2013 at 8:35 PM

I did not change the project file, instead I did the folowing:
  1. I uninstalled and reinstalled the Visual Studio TypeScript plugin. (I did not install Web Essentials)
  2. I made a new "HTMLAplication with TypeScript"-project.
  3. I copyed all my files and folders from the original project to the new project. And then included them in the solution.
  4. I did not copy the root web.config file and global.asax file, but made new ones to make sure they were fully up to date with the .NET version.
  5. I added all the references needed for Asp.Net and C#.
  6. I renamed all the .js files to .ts files.
  7. By right clicking the .ts files I changed the build action from "Content" to "TypeScriptCompile".
  8. I made a references.ts files in the js folder, and added referenceses to this from all the js files. To tie the files together.
  9. I then made sure that all the new .ts files could compile (some changes to the code where needed)
  10. With notepad, I manually changed the project file so that the new output js files got this "DependentUpon", so that they showed under the ts file, like the codebehinds-files.
    (I think 10 may also be needed to fully compile and run)
Achtung: A few of the TypeScript compile errors showed in the normal output, instead as like real errors.
(in the real error there was only the "exited with code 1" message)

Best regards,

Anders Both, Denmark.