Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

7 years ago by inkajoo

I just discovered TypeScript and I'm really excited about its potential to encourage the creation of V8-optimizeable JavaScript, but I'm wondering if there might be any challenges with using it together with Impact.js?

The first potential issue that comes to mind is the require system.

7 years ago by Joncom

It sounds like JavaScript programs "just work" with TypeScript. In other words, if it's already a working JavaScript program, then it's already a working TypeScript program too. So I guess the thing to do is simply start. And slowly convert chunks of code (such as assigning types to variables).

Edit 1:

Just found this video where a guy converts a JavaScript project into a TypeScript project: https://youtu.be/Ut694dsIa8w?t=50m10s

Edit 2:

Actually, I think you were probably right about Impact's module system messing things up a little. The majority of code is defined inside of the defines function and then made accessible via global variables. And I don't think the TypeScript compiler can properly build references to/from all the various classes and properties this way.

So even if you were to specify types for each class property, the compiler would almost never know what class you are talking about, and so basically all the benefits of type checking would be lost.

7 years ago by Joncom

So I was intrigued by the idea of TypeScript + Impact, and so I went ahead and started converting the entire engine over.

All instances of ig.Class are now TypeScript/ES6 style classes. Classes that extend from others now use the class MyClass extends BaseClass { .. } syntax.

The engine runs, and I've got a simple game up and running. The intelligent auto-completion TypeScript offers is pretty cool :)

There's a few things that aren't working yet. For example, I haven't touched Weltmeister. Also, I haven't implemented an equivalent function for ig.Class.inject. But otherwise, it pretty much just works.

Anyway, if anyone is interested in playing around with it, let me know and I'll make a thread in the private forum and grant whoever wants access...
Page 1 of 1
« first « previous next › last »