phaserjs / phaserjs/phaser

Incorrect typing for Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback

Open
#6,784 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 TypeScript Bug
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.80.1
  • Operating system:
  • Browser:

Description

There is a typescript error when I am trying to create RandomZone for ParticlesEmitter.

Example Test Code

const emitRect = new Phaser.Geom.Rectangle()
new Phaser.GameObjects.Particles.Zones.RandomZone(emitRect)

Error:

Argument of type 'Rectangle' is not assignable to parameter of type 'RandomZoneSource'.
Types of property 'getRandomPoint' are incompatible.
Type '(point?: O | undefined) => O' is not assignable to type 'RandomZoneSourceCallback'.
Types of parameters 'point' and 'point' are incompatible.
Type 'Vector2Like' is missing the following properties from type 'Point': type, setTo

Additional Information

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the type definitions for Phaser.GameObjects.Particles.Zones.RandomZone, RandomZoneSource, RandomZoneSourceCallback, and Geom.Rectangle, then compare the callback signatures involved in the reported error. Use the provided RandomZone example to reproduce the TypeScript failure; done means the example type-checks without the incompatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.