Skip to content

TypeScript Errors #6307

Closed
Closed

Description

@subhoghoshX

Version

  • Phaser Version: 3.55.2+
  • Operating system: any
  • Browser: any

Description

When trying to recreate the game using the website's guide, I encountered a couple of TypeScript errors.

In a section while iterating the stars it shows setBounceY not found.

const stars = this.physics.add.group({
  key: "star",
  repeat: 11,
  setXY: { x: 12, y: 0, stepX: 70 },
});

stars.children.iterate((child) => {
  child.setBounceY(Phaser.Math.FloatBetween(0.4, 0.8)); // Here it says `setBounceY` doesn't exist.
  return null;
});

image

And just after that, in the tutorial, where it shows how to detect overlap, the doc shows to use null and this as the 3rd & 4th arguments.

image

But it shows a type error when I pass null.

image

Looking at the type it look like it expects something else:

type screenshot

I encountered the above errors in phaser@3.55.2+ including the latest beta 16.

Activity

  1. subhoghoshX commented on Dec 5, 2022

    @subhoghoshX
    Author

    PS: I know creating an issue is easier than fixing it. I'm quite familiar with JS/TS, if anyone can point me in the right direction, I can try fixing it.

  2. photonstorm commented on Dec 5, 2022

    @photonstorm
    Collaborator

    You need to cast 'child' in the iterate handler or TS won't understand what it is.

  3. subhoghoshX commented on Dec 5, 2022

    @subhoghoshX
    Author

    Cast 'child' to what type?

  4. photonstorm commented on Dec 5, 2022

    @photonstorm
    Collaborator

    To what it is - an Phaser.Physics.Arcade.Sprite.

  5. locked and limited conversation to collaborators on Dec 5, 2022
  6. converted this issue into a discussion #6308 on Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions