How about compiling C# Interfaces to TS interfaces?

Topics: General
Oct 2, 2012 at 2:44 PM

Hi,

Typescript looks great, so thanks a lot for sharing :)!

One area where I can see it will be handy is handling complex objects passed from the server side to the client via json. On the server side I already have C# interfaces describing these objects, because I need the interfaces to write unit tests.

On the client side, it would be very handy to be able to compile Typescript interfaces from those C# interfaces so I could regenerate them automatically with each compiler run.

I know this is not possible yet, but I just wanted to make this suggestion in case it might be handy for other ASP.NET / MVC developers.

Thanks,

Adrian

Oct 2, 2012 at 5:50 PM

At Microsoft we're also hard at work on the Roslyn project, which is out in CTP and which offers a public high fidelity API over C# and VB source code. Based on Roslyn, anyone should be able to go build a converter from C# interfaces to TypeScript interfaces. I imagine that would be a very popular tool!

Mads

Oct 2, 2012 at 7:30 PM

well, if you have interface (in proper architecture always a separate assembly) you can using reflection and little coding write converter in no time.

Nov 14, 2012 at 2:34 PM

+1

This would be very useful in MVC scenarios when posting JSON that gets converted into C# POCOs on the server.

This would be great to add to the Web Essentials project.

 

Dec 13, 2012 at 5:37 PM
Edited Dec 13, 2012 at 5:38 PM

I hacked together a C# to TypeScript interface generator over here: http://typescript.codeplex.com/discussions/406685