title: Automatically generating TypeScript data contract interface from C# JSON service implementation
body: <p>Our C# application provides a number of JSON web-services for the web app client to consume. Currently we generate that JSON reasonably manually through recursive object-to-JSON-dictionary-representation calls.</p>
  
  <p>We're gradually implementing parts of our web app in TypeScript - we'd like to have TypeScript interfaces to define the shape of the JSON data the client code should expect to receive from the server. </p>
  
  <p>Is there a way to automatically generate the TypeScript data contract interface definitions at compile time, based on the C# JSON service implementation?</p>
  
  <p>For example, the C# code generating the JSON currently looks something like this:</p>
  
  <pre><code>    public class ConcreteObj
      {
          public string SimpleProperty;
          public ConcreteObj[] Children;
      }
  
      public static IDictionary&lt;string, object&gt; ConvertToScriptValue(ConcreteObj obj)
      {
          IDictionary&lt;string, object&gt; result = new Dictionary&lt;string, object&gt;();
  
          result["simpleProperty"] = obj.SimpleProperty; // string
          result["children"] = Array.ConvertAll(obj.Children, ConvertToScriptValue); // ConcreteObj array
  
          return result;
      }
  </code></pre>
  
  <p>We'd like to see TypeScript similar to the following:</p>
  
  <pre><code>interface ConcreteObj {
      simpleProperty: string;
      children: ConcreteObj[];
  }
  </code></pre>