How can I have TypeScript build only on save in Visual Studio - visual-studio

When I build the project, it is redundantly building script event though I have script compiling on run/debug. Is there a way to make it only build on save?

If you have installed Web Essentials 2012 extension it is very easy.
In Visual Studio go to Tools -> Options -> Select Web Essentials, Under the TypeScript set "Compile TypeScript on Save" to True

You can set the build type to none and saving the .ts file will still build the .js file. However, the .js file does not get checked in to TFS so when someone gets the project, they would have to open and save every file. This seems to be another issue.

Related

Building a Folder in Visual Studio

I'm working in Visual Studio 2017. I wanted to open a folder of files, so I clicked File -----> Open ------> Folder and selected the folder containing all my files.
When I view the Solution Explorer, I can see all of my programming files. However, I am unable to build my project and run it. Is there any way to build and run a folder in Visual Studio? I've tried selecting the .cpp file that I wanted to build specifically, but there's still no build/debug option.
In fact, under the Debug menu, the F5 Start option is grayed out. Any solutions?
I think you have to create a Visual Studio project first, and then add those files to the project. What you are doing right now is just using VS as an editor and viewer.

Visual Studio 2015 Apache Cordova with TypeScript

I'm using Visual Studio 2015 Update 2 with Apache Cordova Tools Update 8 and TypeScript 1.8.29.
I can't get working the "Build on Save" feature, i tryied to manualy change the property on the project file:
<TypeScriptCompileOnSaveEnabled>true</TypeScriptCompileOnSaveEnabled>
I really need this feature because if VS don't build when i save every time i modify something i must stop debugging, build again, and restart.
I'm sure this should work exactly like less/sass: Modify -> Save -> Build -> Automatic refresh of app.
The part Save -> Automatic/Manual refresh works well, i saw it on css and js.
You need to turn on the "Automatically compile typescript which are not part of a project" option.
open VS->Tools Menu->options->Text Editor->Type Script->Project->check on "automatically compile typescript which are not part of a project".
Please note:
There are two "appBundle.js" files in your project
("/scripts/www/scripts/appBundle.js" and "/www/scripts/appBundly.js"). CompileOnSave only compiles codes to "/scripts/www/scripts/appBundle.js" by default.
You can change the output file by changing the "out" property of "compilerOptions" in tsconfig.json file.

TypeScript only compiles if previously compiled JavaScript file has been deleted

I am using Angular 2 in Visual Studio 2015, inside of an asp .net 4.5 project. When I build and run the project, JavaScript files are created correctly. However, if I make any changes to the TypeScript and recompile, the JavaScript isn't being overwritten. The only way I can get the TypeScript to recompile is by deleting the previous JS file.
I would first suggest opening Visual Studio as Administrator to see if it is a permissions issue, whereby VS2015 cannot overwrite your JS files.
Otherwise, right click on the project in your solution (not the solution itself) and select Properties.
You should have a tab called TypeScript Build as shown in the screenshot below. Ensure that you have Compile on Save checked.
"compileOnSave": true
must be added to tsconfig.json.

Type Script is not generating JavaScript in my Visual Studio Community edition 2015

I am using Visual Studio Community edition 2015 for development, I have added *.ts file to my project but its not automatically compiling. Also it does not show JavaScript preview pane. This post How do I enable the preview panel for TypeScript files in Visual Studio 2015? says that it's not supported anymore. That's fine, but why it's not compiling?
I referenced Missing Typescript Options in Web Essential for Visual Studio 2012
It says Split panes have been reintroduced in the latest version of web essentials http://vswebessentials.com/features/typescript but I can not see it
I do have typescript exe in following folder
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5
I do have settings in Project Properties as follow
I do have settings as follow in Visual Studio
I see comment in http://www.typescriptlang.org/ as below
"Visual Studio includes TypeScript in the box, starting with Visual Studio 2013 Update 2. You can also edit TypeScript in VS Code, WebStorm, Atom, Sublime Text, and Eclipse"
What may be issue?
Solution
My "typings" file for jquery was out dated, I upgraded it and it resolved other errors and build was success, then JS files got generated.
Below post helped
JQuery definition screwed up with TypeScript 0.9
I can not close this question because I am still not able to get 'Preview Pane"
I regularly encounter this issue in VS 2015 and VS 2013. My solution is not a pretty one, but it works for me...
Close Visual Studio
Go to your scripts folder, delete all JavaScript files that have corresponding TypeScript files (only necessary to do this for TypeScript files that you have created for your project)
Open Visual Studio, clean, and build
If this doesn't work, open each TypeScript file, change one character, Save, re-build... hopefully the file will re-compile.
If this still doesn't work, open a Node.JS command prompt, change directory to the scripts directory, run;
tsc "yourfile.ts"
If this doesn't work, you've got bigger problems.
Make sure that you highlight the project in the solution explorer and then click the icon at the top that says "show all files" after you have compiled the project. You will then see the .js and maybe a .js.map file (greyed out). Select the files and then right click and 'include in project' and things should be good from there.
Some false-errors in my ts caused the issue, fixed by uncheck "Do not emit outputs if any errors are reported"
(The false error is from an outdated DefinitelyTyped file, the generated js file does not have any error.)
Maybe not having the option to expand the .ts file and see the generated .js can cause a confusion here.Try to compile your solution. Click on Show All Files and you must see all the .js generated in the same folder of your .ts files. Include your .js in the project if you want to have them visible as part of the solutions. Hope this helps
I know you say you added the .ts file but did you right-click and select 'include in project'. This will add it to the list of files that Visual Studio will check for TypeScript transpiling.
You need install Web Essential then restart the Visual studio -> clean Solution -> Rebuild it should work.

Do not compile t4 file

Suddenly, after doing a TFS 2010 get, Visual Studio 2010 is attempting to compile my .tt file as if it was c#.
Moreover, anytime I set it to "Build Action=None", Build Action gets mysteriously reset to Compile. This is breaking our builds on the desktop. I can get builds to work on the desktop by closing then reopening VS.
Our builds on TFS are totally broken because of this. What to do?
The template generates a (totally ok) c# file, so I need the project to build.
I tried changing the file extension from .tt to .donotbuilddammit but that had no effect.
Are you by chance using the Clairus T4 plugin (or another T4 intellisense provider)?
If so, try making sure the files are not open when you change the BuildAction setting.
Visual Studio builds intellisense
based on the compile action of your
files. It will only provide
intellisense for files that are marked
as "compile". Because of that, we
change the build action when the file
is open, and we change it back to
whatever it was before when checking
in, closing the file, closing Visual
Studio and also when opening Visual
Studio (in case it crashed)
See: http://forums.clariusconsulting.net/viewtopic.php?f=12&t=445

Resources