This project is read-only.

TypeScript Macro-/Pre-Processor for Visual Studio and C#

Topics: General
Jul 24, 2014 at 12:11 PM
Hi all,

We use TypeScript a lot in ASP.Net MVC projects for implementing the client-side code (MVVM, Ajax, etc). We always face the problem that TypeScript/Javascript code is out of sync with C# server-code as R# and other Tools don't get over the "technology gap" from C# to TypeScript.

For example when the server returns JSON objects and one of the fields get renamed one need to search the whole TS sourcecode and renamed it there by hand otherwise the client doesn't work as expected anymore. This also adresses MVVM pattern where the HTML markup (and therefore the binding) is generated by Razor/C# and the client-viewmodel by TypeScript. Same problem.

One solution to this that cam in mind is a TypeScript Pre-Processor or Macro's. It would be very cool if I can mix C# code (eg. constants like field-/property-names into the TypeScript code. This stuff gets updated each time before the TS compiler starts and does generate the TS sourcecode before it get to the TS compiler.

Is may be a way to bridge the technology-gap and may allow to fix a lot of problems because the same constants (eg. names) can be used in server-side C# code as well as in client-side TS code. Same would apply to plain Javascript code instead of TypeScript.

Does anything like this already exists? How did you handle that gap between client and server code? How to keep things in sync? Any feedback to such an approach?