Using TypeScript with Coherent UI
Previously we announced the automatic binding of .Net methods for Coherent UI. It greatly simplifies exposing the game to the UI, but also has some additional advantages that I want to share. Binding .Net methods allows to expose the game using concrete, separate interfaces. This allows for better structuring of the UI code – think of OOP and separation of concerns. It also allows for taking advantage of more advanced and modern web programming techniques, tools and languages like TypeScript.
What is TypeScript?
- optional static typing – catch errors while making them
- lots of EcmaScript 6 features – arrow functions, classes with inheritance, modules
- much better editor support – autocompletion and error highlighting in Visual Studio
Say you have a Player class with inventory consisting of list of items
You need to declare the Player class and the Item struct in order to take advantage of the static type checks.
In its next release TypeScript is going to have two major new features – generics and overloading on constants. They are going to make using Coherent UI with TypeScript even better and so expect more posts about using TypeScript with Coherent UI.
Follow Dimitar on Twitter: @DimitarNT