Jump to content

Phaser 2.0 and Typescript issues


Manifest
 Share

Recommended Posts

Hi all,

 

I've just updated my Typescript project's version of Phaser from 1.1.2 to 2.0, and I'm having issues. On rebuilding the project, I got a few hundred errors - a handful of them were as a result of changes made to Phaser such as stage.scaleMode etc, and I have fixed those. The majority of the errors on the other hand, seem a bit less obvious.

 

Example:

this.m_background = new Phaser.Sprite(AppData.app, 0, 0, "timerPanel");
Error 5 Build: The property 'Sprite' does not exist on value of type 'typeof Phaser'.
 
I have 125 of these errors, occurring on classes: Sprite, Point, Signal, Loader, Rectangle, Text, Button...to be honest, it's probably every Phaser class that I reference via Phaser.something(). It's as though it doesn't know what Phaser is anymore.
 
Is this an issue with the yet-to-be-fully-updated phaser.d.ts?
 
Link to comment
Share on other sites

Hey Rich,

 

I should've mentioned - I've already tried that one from the dev branch, same issue.

 

It seems that if I delete the Phaser class from the definitions file, and leave the module, it works but then obviously I'm missing the constants. It feels more like a typescript issue, in that it can't differentiate between a class and a module - which is weird, because the old phaser.d.ts worked exactly the same.

Link to comment
Share on other sites

Hey Manifest. 

Yeah I have had this multiple times.  When I update the phaser.d.ts file in Visual Studio, it always breaks my references. 

What I generally resort to is primitive methods:

-Copy phaser.d.ts somewhere, delete it from the project, then paste back the file to your project

-Do the same, but close Visual Studio before pasting back the file. 

-Hit Rebuild / Clean / Rebuild / Run and sometimes it works. 

Also for me Visual Studio 2013 with TS1.0r destroys my entire visual studio. No auto completion nothing.  So I am stranded on 0.9.5 hopefully until the VS spring update. 

But yeah its really annoying stuff.  

Link to comment
Share on other sites

Thanks for the response clark - yeah, TS-VS compatibility certainly leaves a lot to be desired. I tried your suggestions, but unfortunately they don't seem to have any impact on my VS 2012 + TS 1.0r (or 0.9.5). [interestingly, I still get auto complete with TS1.0r + VS12]

 

I did however do some more experimenting, and placing the phaser class after the module seems to have fixed things for me. It still finds all the constants I need e.g. Phaser.CANVAS etc, and it sees the Phaser.classes . It could be a fluke and maybe something's still cached somewhere on my machine, but it might be worth giving that a try the next time you get those errors.

Link to comment
Share on other sites

Just upgraded from 1.6 to 2.0 and had similar issues with VS2013 typescript plugin not understanding the new phaser.d.ts file.  I managed to get the unknown type build errors to dissappear by editing the phaser.d.ts file:

 

Move the "declare class Phaser {..." declaration to after the "declare module Phaser {..." declaration.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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