Not a Javascript dude nor an Html dude and I just wanted to look at that....

Topics: General
Oct 11, 2012 at 3:38 PM

My expertise is C# and Silverlight.  Well yes I did some ASP.NET page but I never wrote a single line of Java in my entire carreer and I'm very proud of this.

That said,  I just started to peek a little on TypeScript and see that there's a lot of progress needed.  This is very yong and I hope it'll not stay yong too long.  There's a lot not to my taste in there.  Having to use a command line is very poor and the VS 2012 plugin is just an intellisence.  That's not prety huge but maybe this will change ?

Having the possibility to write my usual C#.NET code and have it compile in .js would be asking too much of course.  Specially if we write xaml. 

I have a very tiny question here.  Will we all end up with HTML and JS in the future for developping the web or we'll really be able to use our huge bag of .NET knowledge in C# + XAML and yet being able to target all platforms and all browsers ?

 

Oct 11, 2012 at 3:42 PM

C# questions aside (I couldn't care less if we never get that available on the web, it's best left on desktop) - you don't need to use the command line to compile. Just hit F5 like everyone else in Visual Studio. The plugin is more than just intellisense. Not much more, but enough to make development far less painful than in other editors.

Oct 11, 2012 at 5:37 PM

I do F5 and all it does is run the application but the .js isn't generated at all.
Am I missing something ?

Oct 11, 2012 at 5:56 PM
geardoom3 wrote:

My expertise is C# and Silverlight.  Well yes I did some ASP.NET page but I never wrote a single line of Java in my entire carreer and I'm very proud of this.

That said,  I just started to peek a little on TypeScript and see that there's a lot of progress needed.  This is very yong and I hope it'll not stay yong too long.  There's a lot not to my taste in there.  Having to use a command line is very poor and the VS 2012 plugin is just an intellisence.  That's not prety huge but maybe this will change ?

Having the possibility to write my usual C#.NET code and have it compile in .js would be asking too much of course.  Specially if we write xaml. 

I have a very tiny question here.  Will we all end up with HTML and JS in the future for developping the web or we'll really be able to use our huge bag of .NET knowledge in C# + XAML and yet being able to target all platforms and all browsers ?

 

You mean JavaScript, not Java. They're two different languages. I also find it very odd for a developer to be proud of the fact that he has no knowledge of a certain technology.

That aside, TypeScript is not for you. Knowing JavaScript first is a necessity in order to write TypeScript. If you're waiting for the day when someone creates some magic technology which converts C# and XAML into JavaScript/HTML, you're going to be waiting a long time. There's simply far too many differences between the two development methodologies to make them compatible without a lot of compromises.

Oct 11, 2012 at 6:07 PM
geardoom3 wrote:

I do F5 and all it does is run the application but the .js isn't generated at all.
Am I missing something ?

If it's run the app.ts then it has generated JavaScript, it's impossible for it to not do so (nothing would run otherwise). Just look in your project folder.

Oct 11, 2012 at 6:13 PM
Edited Oct 11, 2012 at 6:15 PM

PhotonStorm :

You better try yourself as I have just one .ts in the folder, and when I run the app, there's absolutely no .js generated from the .ts.  The only way I can have the .js is by doing everything manually hence going in command prompt, typing tsc test.ts to generate teh .js then go in my project and add existing item and pick the .js.  Wow this is absolutely awful!

 

Oct 11, 2012 at 6:14 PM
Edited Oct 11, 2012 at 6:15 PM

MgSam :

I understand.  So the best way to have my web app seen everywhere is to use ASP.NET which is the closest technology to me that will be available everywhere right ?

 

Oct 11, 2012 at 6:27 PM
Edited Oct 12, 2012 at 5:46 PM

Ahhhhhhhhh I finaly see that I started a web project from scratch and I did not use the HTML for TypeScript that was generating all the goodies for me.
Now it works if I modify the .ts it compile the .js automatically and is under the .ts.  Now I have to learn the easy way of calling a WCF service from JavaScript.  I know that I do it from scratch I will kill myself using a rope somewhere but there's certainly librairies already written for us.  Ahhhhhhh the good way of starting to learn JavaScript.  In fact I just wanted to see how far I would go before killing myself.  This language it's plain terrible.

 

Oct 11, 2012 at 6:34 PM

Install Sholo.TypeScript.Build via NuGet and your .ts files will generate .js files automatically. Add new .ts files via Add new item from Solution Explorer. I wrote simple script to recompile .ts files without recompilation whole project. Here is it

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;

class Script
{
	public static void ProcessFile(string file) {
		Process myProcess = new Process();
		myProcess.StartInfo.FileName = "tsc";
		myProcess.StartInfo.Arguments = file;
		myProcess.StartInfo.RedirectStandardOutput = true;
		myProcess.StartInfo.UseShellExecute = false;				
		myProcess.StartInfo.CreateNoWindow = true;
		myProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(file);
		try
		{
			myProcess.Start();
			StreamReader output = myProcess.StandardOutput;
			Console.Write(output.ReadToEnd());
			myProcess.WaitForExit();
		}
		catch (System.Exception)
		{
			Console.WriteLine("Can't compile file"+file);					
		}
	}
	
	public static void ProcessFiles(string[] files)
	{
		foreach (var file in files)
		{
			ProcessFile(file);
		}			
	}

	static void Main(string[] argv)
	{
		FileAttributes attr = File.GetAttributes(argv[0]);
		if((attr & FileAttributes.Directory) == FileAttributes.Directory) {
			var files = Directory.GetFiles(argv[0],"*.ts",SearchOption.AllDirectories);
			ProcessFiles(files);
		}
		else
			ProcessFile(argv[0]);
		Console.WriteLine("ok");
	}
}

and add new External Tool using Tools->External Tools Menu->Add, Use Output window must be checked to see results in output window after recompilation. Enter you name for me it is "Compile TypeScript" enter command S:\cs-script\cscs.exe - cs-script i use for console scripting here is it http://www.csscript.net/ you can use another script language. Than enter arguments "s:\_Proj\Tools\typescript.cs $(ItemPath)". So now you can recompile current file by selecting Tools->Compile TypeScript but it is better to add this command to the Solution Explorer's context menu to have the ability to recompile whole folder with .ts files or any single file using Solution Explorer.

To do this go to Tools->Customize than select Commands tab and select Context menu, find "Project and Solution Context Menus | Item" than press "Add Command" In the opened dialog select Tools and than select External Command n - where n is you external command order in Tools->External Tools menu, than click Ok select new item in menu and presss Modify Selection to describe name for your new menu item.

You must to do similar actions to add new menu item for folder's Context menu. Go to the Tools->Customize again but find "Project and Soludio Context Menus | Folder" and make same actions that you do with  "Project and Solution Context Menus | Item".

Now you can select file that you need to recompile and select Compile TypeScript in the context menu or you can do it on whole folder with scripts inside.

Oct 11, 2012 at 7:08 PM
geardoom3 wrote:

Ahhhhhhhhh I finaly see that I started a web project from scratch and I did not use the HTML for TypeScript that was generating all the goodies for me.
Now it works if I modify the .ts it compile the .js automatically and is under the .ts.  Now I have to learn the easy way of calling a WCF service from JavaScript.  I know that I fo go from scratch I will kill myself using a rope somewhere but there's certainly librairies already written for us.  Ahhhhhhh the good way of starting to learn JavaScript.  In fact I just wanted to see how far I would go before killing myself.  This language it's plain terrible.

 

You can borrow my rope.