Jump to content

Typescript Phaser "Cannot find name 'Phaser'"


Recommended Posts

I just followed this tutorial for getting Phaser 2.4.8 set up using TypeScript (with VS 2015) and, initially, everything works fine... the first time. However, if I make any modification to the app.ts file and try to run the project a second time, I get a ton of errors complaining about pixi.d.ts and other files missing (even though the tutorial mentions nothing about needing them).

However, if I then comment out the this.game.add.tween()... line and try again, the project will successfully run, and then if I uncomment the this.game.add.tween()... line and run again, the project works with the changes! BUT if I make any more changes, I have to repeat the comment, run, uncomment, run process again before it will compile and work with the change.


What gives? I've followed the tutorial on a new TypeScript VS project twice, just to make sure I didn't mess something up the first time. For some reason, it demands extra files sometimes but not other times. How do I get around this?

Link to comment
Share on other sites

This is still a problem. I'd really like some help with this, as I hesitate to put much time into something that doesn't seem to work. Any clue as to why this doesn't function correctly?

If I look at phaser.d.ts, Visual Studio seems to have a lot of issues:


What am I not understanding here? It looks pretty clear like those other files are required, yet the tutorial clearly says otherwise. Why does it compile and work sometimes but not other times? I'd really appreciate some answers!

EDIT: And if it makes any difference, the 2.4.9 RC2 also has the same bunch of errors when I replace phaser.d.ts with the new one.

Edited by cybearg
Link to comment
Share on other sites

So I've gone through the tutorial again, this time using 2.4.9 RC2, since by the sound of it there is a bug in 2.4.8 where certain important things are missing (wonder how that slipped past without being noticed?), and I've gone ahead and included the p2.d.ts and pixi.d.ts files along with the rest, even though the tutorial makes it seem like those files aren't needed.

... And I'm in the same situation, with tons of "Cannot find name 'Phaser'" errors:


What's wrong, and how do I fix it?

I don't know why I'm not getting answers to this issue. Is there a secret handshake I need to know in order to get some help, or something? Everyone who uses Phaser should know the answer to this question, so please, someone give me a response!

Link to comment
Share on other sites

Hi, I use Phaser + Typescript + VS2015 and it works well.

Some time ago I wrote tutorial (http://sbcgamesdev.blogspot.cz/2015/05/phaser-tutorial-dronshooter-simple-game.html), which is for VS2013, but it is still valid (only skip part with setting web.config file)

From screenshots you attached it seems, you included phaser.d.ts file, but you are missing pixi.d.ts - copy it into same folder (or you can, like me, put all these *.d.ts files into separate folder called lib). Also add p2.d.ts file - on your second screenshot (top of phaser.d.ts), both files are in red, as they are missing.

Link to comment
Share on other sites

On 6/14/2016 at 2:27 AM, stamas47 said:

You need to add the pixi and the p2 declaration files to your project as well.

I did eventually do that, yes, but then I hit this bug, preventing me from doing anything. I'm now trying out the latest 2.4.9, but it also has errors and won't compile:


Needless to say, this is very frustrating. Apparently 2.4.8 and 2.4.9 work well enough for everyone else for it to pass some kind of QA, so why does it refuse to work for me at all?

On 6/14/2016 at 2:01 AM, Tom Atom said:

Some time ago I wrote tutorial (http://sbcgamesdev.blogspot.cz/2015/05/phaser-tutorial-dronshooter-simple-game.html), which is for VS2013, but it is still valid (only skip part with setting web.config file)

That tutorial looks great! I can't wait to try it out... once Phaser decides to allow me to use it. :(


Link to comment
Share on other sites

20 hours ago, Tom Atom said:

Hi, I put GitHub issue with it (https://github.com/photonstorm/phaser/issues/2568). You can read it and adjust phaser.d.ts and pixi.d.ts according to it.

Always read those red errors - it often tell you where is problem. Bullet is part of Weapon plugin, which is brand new in Phaser.

Thanks so much! I really felt like I was all alone there, and it was very frustrating. :(

What puzzles me though is how am I seemingly the only person with these issues? Surely SOMEONE else has used 2.4.9 and 2.4.8 before and noticed that neither will compile. Is there something I'm missing?

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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