10/30/2014

Typescript incomming...

From the start of implenting games with javascript in 2013 I did not like the lack of precise auto completion in webstorm. Of course this is not webstorms fault, there is just no way of knowing what to auto complete without typed variables.

Another annoyance: small typos in javascript go unnoticed until the code is executed and even then the behavior sometimes is just strange and the error is not clearly identifiable.

This might be fine or at least tolerable for small scripts, even small games. But I already got fed up with it. (Especially because I see what intelliJ (and therefor webstorm) is capable of with  its indexing power, code completion and refactoring when I edit the Java code at work.)

The solution seems to be typescript. After reading up on it I just started converting the game and it's going fine so far. My biggest javascript file (the "dungeonObject") is already converted into typescript, and with some minor modifications (and minor bugs) the game can already be played again. (Even though the rest of the code is still pure javascript.)

A quick example of one of the benefits:
yay, typing!
Webstorm can tell me this, because the array is declared as:

export var clickableMeshObjects:THREE.Mesh[] = [];

I think this will be very helpful and enable me to find many errors without even having to start and test the game.

No comments:

Post a Comment