This project is read-only.

TypeScript interfaces from .NET classes

Topics: General
Mar 19, 2013 at 9:25 PM
I have seen several questions about generating TypeScript interfaces from C# classes in this forum. Because I need such tool as well, I wrote an utility that generates TS interfaces from .NET assemblies in Visual Studio (using T4 template). It supports most of the TypeScript features including modules, collections and inheritance.

namespace Demo {
    public class Person {
        public string Name { get; set; }
        public List<address> Addresses { get; set; }
    public class Employee : Person {
        public decimal Salary { get; set; }
    public class Address {
        public string Street { get; set; }
module Demo {
    interface Person {
        Name: string;
        Addresses: Address[];
    interface Employee extends Person {
        Salary: number;
    interface Address {
        Street: string;
The utility is available as NuGet package, documentation and tutorials can be found on the project webpage
Mar 20, 2013 at 12:34 PM
Edited Mar 20, 2013 at 12:34 PM
Nice work, I was planning on doing something like this myself too already. :) I probably still will, but with a different approach.

I just think T4 is a bad option for this. You either always have to run it manually when changing something (which people will definitely forget!).
Mar 20, 2013 at 1:46 PM
I agree, this isn't the ideal solution. I'm thinking of a tighter integration with build process - perhaps a MsBuild task, that would generate TypeScript interfaces during the build process. Does anybody have a better idea? (I just don't want to use VS Extensions, because they aren't working in Express editions of Visual Studio.)
Mar 20, 2013 at 2:48 PM
I am working on a solution for such problems. Next weekend I can tell you more about it by releasing a first version, if you can wait this long. :-)