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

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.

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.

Unity Project doesn't have solution file

I just started learning unity and I created a project. But my project doesn't have a sln file included in. Every time I create a C# script and open it in Xamarin Studio I can't have any intellisense.
Is it normal not to have sln file in unity project?
If not, how can I add solution file to project?
Why that happened?
If "Open C# Project" doesnt create the .sln file, try updating your external tools first.
In Unity, go to Edit > Preferences, and make sure that Visual Studio is selected as your preferred external editor.
This created the sln file for me.
I finally found the answer.
I closed Xamarin and inside Unity went Assets > Sync MonoDevelop Project Doing this created the two .sln projects: -csharp.sln and .sln
For people looking for answers on newer versions of Unity you may have to build your C# project.
To do this go into File > Build Settings then select the option Create Visual Studio Solution. Then build that and your file explorer will ask you for which folder you want your visual studio solution to be placed into. Then Visual Studio should behave correctly.
For people looking for answers on newer versions of Unity you may have to build your C# project.
First install windows build also in unity hub then select target platform to windows. and now you can see visual studio solution checkbox.
To do this go into File > Build Settings then select the option Create Visual Studio Solution. Then build that and your file explorer will ask you for which folder you want your visual studio solution to be placed into. Then Visual Studio should behave correctly.
Like the post by SSchmid suggests, go into preferences and have Visual Studio as your preferred editor.
I was having a sync issue and the Solution wasn't showing the name of the unity project, ultimately interrupting intellisence.
Found in my settings that the code editor was set to General and not Visual Studio specifically.
Setting it to VS solved it for me.
A screenshot to help those who are too lazy to read.

How can I have TypeScript build only on save in 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.

Create a new TypeScript project in Visual Studio

How do I start writing TypeScript projects in Visual Studio? There's no option for it when I create a new project. I have Visual Studio 2012 installed along with the TypeScript add on
I just found the solution: Manual installation of the VS-Extension.
In some way, the VS-Extension is not getting installed. You can do it manually. There is a .vsix file located in C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0 called TypeScriptLanguageService.vsix.
Try to run this file. It should install the TypeScript extension.
If you are running an x86-based system, try to look at C:\Program Files\Microsoft SDKs\TypeScript\0.8.0.0.
Worked for me. Now I can create TypeScript projects and it is listed in the Visual Studio extension list.
Note that the newer versions of TypeScript dropped the folder 0.8.0.0. You may find the .vsix file in C:\Program Files (x86)\Microsoft SDKs\TypeScript.
You can add TypeScript files to an existing project using the Add > New Item dialog.
You can also create a project of type HTML Application with TypeScript using the Add > New Project dialog. This project type is under Installed->(Templates)->Visual C#.
If these options are missing from Visual Studio, you should try re-installing the TypeScript Visual Studio plugin.
If you use Visual Studio 2017, the template 'HTML Application with TypeScript' has been removed from the templates.
But you can install the extension made by rich-newman on Github: https://github.com/rich-newman/typescript-html-application-vs2017-template
To install it do the following:
Go to the 'Add New Project' window
At the left go to 'online' in the left tree view
Search for 'TypeScript HTML Application Template'
Install the extension and the template should be available under 'installed --> TypeScript'
Followed the other answers but could not locate TypeScriptLanguageService.vsix after installing TypeScriptSetup.0.8.0.msi on Win7 64 w/ VS 2010.
To install on VS 2010, use 7zip to open the above msi and extract "TypeScriptLS.vsix_File", remove the trailing _File, and run as usual.
This gives a new TypeScript project template (but not a file template mysteriously), intellisense, code highlighting, etc.
I didn't have the project and ts file templates also, tried reinstalling it(just by running vsix file) that didn't help, so I
1. uninstalled(from the VS2012 manager) the extension
2. closed VS2012 and then installed it again and voila-
the Project and file template magically appeared. Thank god it worked- I can start playing with the language without having to run transcompilation manually every time.
Installing typescript adds a new project type as well as adds a file type for existing projects. After installing typescript, you can try searching "typescript" in the new project window. It shows "HTML Application with TypeScript" to me.
Every .ts file typescript file will add a dependent .js file.
Hope this helps!
Old post, new suggestion:
I've spent a few hours on this issue on Win8/VS2012. After multiple install/reinstall (of Typescript plugin v 0.8.3), the one thing that worked, was to run VS2012 in Administrator mode and (re)install Web Essentials 2012. That did the trick for me and I got Typescript as it's own section in Add New Project... (and all the other goodies mentioned above).
What reminded me of the run in admin mode was the process to update documentation (if you want to install documentation locally) where it too had an annoying cryptic error. Running in admin mode was also the answer.
You don't have to run in admin mode all the time, just probably a good practice when updating the IDE itself (new plugins, etc.).
For version 0.9.1.1 I was able to make it work following the instructions here: http://typescript.codeplex.com/wikipage?title=Compile-on-Save.
Support for Typescript was just disabled on Web Essentials 2012 3.0: http://vswebessentials.com/changelog
Another tip - you need to install Visual Studio for Web. It will not work with just VS for Desktop. Also, you need to install the plugin after VS, so if you installed the plugin first, uninstall it then reinstall.
I spent days on this issue too. Eventually found this (very old) answer. Didn't quite help. I have VS 2022 and under Extensions/ Manage Extensions, searched for Typescript and found 'Typescript HTML Application Template'. Downloaded it, created project from it, set the start page and it all seems to work :-)
It was also a simple matter to add a tsconfig.json file. (Not forgetting to put a "dom" in the "lib" line: Mine was
"lib": [ "es6", "dom" ],

Typescript not installed in VS2012? [duplicate]

How do I start writing TypeScript projects in Visual Studio? There's no option for it when I create a new project. I have Visual Studio 2012 installed along with the TypeScript add on
I just found the solution: Manual installation of the VS-Extension.
In some way, the VS-Extension is not getting installed. You can do it manually. There is a .vsix file located in C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0 called TypeScriptLanguageService.vsix.
Try to run this file. It should install the TypeScript extension.
If you are running an x86-based system, try to look at C:\Program Files\Microsoft SDKs\TypeScript\0.8.0.0.
Worked for me. Now I can create TypeScript projects and it is listed in the Visual Studio extension list.
Note that the newer versions of TypeScript dropped the folder 0.8.0.0. You may find the .vsix file in C:\Program Files (x86)\Microsoft SDKs\TypeScript.
You can add TypeScript files to an existing project using the Add > New Item dialog.
You can also create a project of type HTML Application with TypeScript using the Add > New Project dialog. This project type is under Installed->(Templates)->Visual C#.
If these options are missing from Visual Studio, you should try re-installing the TypeScript Visual Studio plugin.
If you use Visual Studio 2017, the template 'HTML Application with TypeScript' has been removed from the templates.
But you can install the extension made by rich-newman on Github: https://github.com/rich-newman/typescript-html-application-vs2017-template
To install it do the following:
Go to the 'Add New Project' window
At the left go to 'online' in the left tree view
Search for 'TypeScript HTML Application Template'
Install the extension and the template should be available under 'installed --> TypeScript'
Followed the other answers but could not locate TypeScriptLanguageService.vsix after installing TypeScriptSetup.0.8.0.msi on Win7 64 w/ VS 2010.
To install on VS 2010, use 7zip to open the above msi and extract "TypeScriptLS.vsix_File", remove the trailing _File, and run as usual.
This gives a new TypeScript project template (but not a file template mysteriously), intellisense, code highlighting, etc.
I didn't have the project and ts file templates also, tried reinstalling it(just by running vsix file) that didn't help, so I
1. uninstalled(from the VS2012 manager) the extension
2. closed VS2012 and then installed it again and voila-
the Project and file template magically appeared. Thank god it worked- I can start playing with the language without having to run transcompilation manually every time.
Installing typescript adds a new project type as well as adds a file type for existing projects. After installing typescript, you can try searching "typescript" in the new project window. It shows "HTML Application with TypeScript" to me.
Every .ts file typescript file will add a dependent .js file.
Hope this helps!
Old post, new suggestion:
I've spent a few hours on this issue on Win8/VS2012. After multiple install/reinstall (of Typescript plugin v 0.8.3), the one thing that worked, was to run VS2012 in Administrator mode and (re)install Web Essentials 2012. That did the trick for me and I got Typescript as it's own section in Add New Project... (and all the other goodies mentioned above).
What reminded me of the run in admin mode was the process to update documentation (if you want to install documentation locally) where it too had an annoying cryptic error. Running in admin mode was also the answer.
You don't have to run in admin mode all the time, just probably a good practice when updating the IDE itself (new plugins, etc.).
For version 0.9.1.1 I was able to make it work following the instructions here: http://typescript.codeplex.com/wikipage?title=Compile-on-Save.
Support for Typescript was just disabled on Web Essentials 2012 3.0: http://vswebessentials.com/changelog
Another tip - you need to install Visual Studio for Web. It will not work with just VS for Desktop. Also, you need to install the plugin after VS, so if you installed the plugin first, uninstall it then reinstall.
I spent days on this issue too. Eventually found this (very old) answer. Didn't quite help. I have VS 2022 and under Extensions/ Manage Extensions, searched for Typescript and found 'Typescript HTML Application Template'. Downloaded it, created project from it, set the start page and it all seems to work :-)
It was also a simple matter to add a tsconfig.json file. (Not forgetting to put a "dom" in the "lib" line: Mine was
"lib": [ "es6", "dom" ],

Resources