VS2013 does not add Javascript generated from Typescript to auto-generate

This is my first time using TypeScript. I am using Visual Studio 2013 Update 4, Web Essentials Update 4, and have the latest TypeScript from the Microsoft website. However, following the tutorial does not work for me: when saving a TS file, it is automatically compiled to JavaScript on the screen to the right of the code I entered, and a JS file is generated in the folder. However, this file is not automatically added to the project. How do I install Visual Studio 2013 to automatically add generated JS files to a project?

+3


source to share


2 answers


Besides Basarat's answer, which works, there is another solution: do nothing. TypeScript generates a JavaScript file that is automatically placed in the same folder as the TypeScript file. When in Visual Studio, right click on the folder where your TypeScript is located and select "open folder in file explorer". You should see that the folder contains both the TS file you made and the generated JS file.



You don't need to add this JS file to your project folder inside Visual Studio: you can just link to it. If you have an MVC project with a Scripts folder that has a greeting.ts file (the one you do in the TypeScript tutorial), the path will be "~ / Scripts / greeting.ts". Instead, simply use the "~ / the Scripts / greeting. Js " (ending on the js instead ts). Visual Studio is smart enough to figure this out. This also works with packages.

+1


source


How to install Visual Studio 2013 to automatically add generated JS files to a project

Use glob for your TypeScript folder i.e. modify your .csproj file to include:



<Content Include="client-src\**\*.*">
</Content>

      

+5


source







All Articles