Sign in to follow this  
Antriel

[WIP] Phaser 3 TypeScript Definitions

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).

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Nowhere yet, I'm currently waiting for instructions.
PR towards the defs would be mostly pointless as the defs are generated and PR towards the code are also mostly pointless as the majority of issues is with the docs themselves not the generator.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.