Just did this up yesterday from Tobias ’ fork and integrating other Typescript forks on github, trying to find the best workflow for Hot-reloading on http within Playcanvas editor/launch runtime and VIsual Studio Code.
I tested the Typescript example which I modified/fixed to confirm it’s working as expected. Also works with normal JS as well. I’m using this template for actual stuff (not just poc examples).
With Typescript, the objective is to try to get the best intellisense (and I’m getting really good results with Visual studio code so far), and best possible DRY as in the following example: https://github.com/Glidias/playcanvas-typescript-babel-intellisense-template/blob/master/src/example.ts . But even on the normal example.js version, you can still get good typings nevertheless, with the .prototype class approach.
In order to get Typescript classes to work with domain-specific Playcanvas’ script instances, I used somewhat a similar approach to what I did with Haxe classes to Vue component objects. But of course, in Typescript, without Macro-ing (in Haxe), runtime decorators have to be used with a slight processing overhead per script. Generally though, I’d use this mainly to manage high application level scripts only, so it shouldn’t be too much of an issue. Notice that I also added script
@attrib decorators as well to ensure your attribute names and declared attribute variables (supplied from Playcanvas editor) line up easily with full type-checking within your class!