In recent ASP.NET MVC Web application I am working on, I need to write lots of knockout code for data binding. The code started to become very messy. It would be hard for colleagues later to maintain it. There are also some other missing features for JavaScript coding in general. For example, if I want to rename a variable, there is no refactoring feature like we have for C# in Visual Studio. One good solution comes to mind was using TypeScript. It's basically another layer above JavaScript. It helps us write strongly typed code and TypeScript complier will help us compile into standard JavaScript. And since TypeScript is just a superset of JavaScript, we can still mix normal JS code with TypeScript code. Let's start to create a simple application to wire up TypeScript with Knockout in Visual Studio 2015. Step1: Open VS 2015 and create a empty ASP.NET Web Application. Step2: Add a folder called Scripts under solution. And then add a new TypeScript(.ts) file Step 3: Write some simple TypeScript code: If you press "Show All Files" button, you will see the auto-generated js file for your TypeScript code.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
Better code,Uncategorized,KnockoutJS,TypeScript
Better code,Uncategorized,KnockoutJS,TypeScript
No comments:
Post a Comment