TypeScript Proxy Generator


Every model in your API, you want to have in your TS Client, must have the following attribute:


There has to be a “.tt” file (T4 Template) in your client with the following content:

<#@ include file="$(ProjectDir)TypeScriptProxyGenerator\ServerModels.ttinclude" #>

The name of this file will also be the name for the generated “.ts” file. For example: ServerModels.tt will result in ServerModels.ts


Controllers that should be available in your client must have the following attribute:


Every method in this controller will be generated within your client. Individual methods can be ignored by adding the following attribute to them:


Also place “.tt” where you like your proxy to be generated. There are two different generators for the proxy:


This will generate a proxy based on AngularJS without a dependency to jQuery.

<#@ include file="$(ProjectDir)TypeScriptProxyGenerator\ServerProxyAngular.ttinclude" #>


This will generate a proxy based on jQuery

<#@ include file="$(ProjectDir)TypeScriptProxyGenerator\ServerProxy.ttinclude" #>

Generate files

To generate the “.ts” files you can right click on the “.tt” file and select “Run custom tool”.

You also can do: “BUILD” > “Transform all T4 Templates” and all files in your solution will be generated.

Last edited Jul 2, 2015 at 9:48 AM by KirKone, version 2