Phaser By Example Book with Typescript

Just sharing here in case anyone else finds it useful. I was interested in using Typescript since I use it everyday as a professional web developer, however I often times found it quite frustrating to work with the Phaser types, and I wasn’t finding very much helpful information online as many of the examples out there are written in JS and often times do things that are not ideal in a Typescript manner.

So I have done my best to start converting the Phaser By Example Book’s source code into Typescript. I absolutely refuse to use the dreaded any, since to me that’s the equivalent of just not using Typescript which doesn’t help out developers who want Typescript. I also do my best to avoid using type assertions (the as keyword) … however unfortunately there are many things I just could not solve without them, since Phaser’s built in types don’t use generics there are many issues around collections, groups and layers.

So I am sharing my initial attempt here in case anyone else would find it useful. I have converted the Runner and Starshake examples so far.

1 Like