Jump to content

[WIP] Phaser 3 TypeScript Definitions


Antriel
 Share

Recommended Posts

Compiled down the current version of the TS defs for Phaser 3.
It's work in progress and hackishly processed to be valid (i.e. doesn't generate TS errors), but it seems to work.

Get it here: phaser.d.ts

Let me know if there are issues (although there's already plenty that I know of).

Link to comment
Share on other sites

Are member variables working for you? They don't appear to be working for me in your build:
image.thumb.png.9c2dbae23a3ed9d85d4fc8485d29e951.png
Have you found a solution to this yet because I haven't found a solution other than to manually add JSDocs (which would require changes to the source / PR requests), or possibly hacky importing and evaluating of modules from the source and writing a custom parser afterwards from any useful data in the middle of my tsd compilation/transpilation process. Which would be a problem since Scenes appear to have properties or as phaser calls it "plugins" dynamically added to them at runtime and Phaser registers all the plugins when phaser.js is require'd (giving the plugins the necessary mappings to match up with InjectionMap and then becoming Scene property names) which includes calls to global browser objects like "window", which will crash nodejs. Both of these solutions are not ideal and very tedious. Currently, the JSDocs in the source do not appear to be very "TypeScript friendly" for automatic generation. Ideally, I was hoping for TypeScript support on release as stated in the Phaser World dev log over two weeks ago so that I could start my projects. 

Link to comment
Share on other sites

First step is getting the jsdoc convert to valid TS defs without any hacks. That will require lot of fixes in the actual jsdoc.

Then we can think about these dynamic plugins, possibly adding custom jsdoc tag for it. It shouldn't be too difficult I hope. In any case it will definitely have to be automatic and based on the jsdoc, not custom per-plugin manual hacks in the converter or anything like that.

By the way, a lot of work already went into the jsdoc being TS friendly, but it's more difficult than it might seem on such a big project. JSDoc itself doesn't help there much either :D

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...