TypeScript error when adding a group to a scene since 3.5.0

I have updated a project to Phaser 3.53.1 (from Phaser 3.4.something). I have some custom Groups which now return TypeScript errors when adding them to a scene using scene.add.existing(group).

Example code:

class GroupNew extends Phaser.GameObjects.Group {
  constructor(scene: Phaser.Scene) {
    super(scene);

    this.scene.add.existing(this); // Returns "Argument of type 'this' is not assignable to parameter of type 'GameObject'."
  }
}

I am not sure whether this is a typing problem in the latest version of Phaser or whether I should change my approach when adding custom groups to scenes.

Typing problem.

Okay thanks samme. As a temporary work around I am using:

this.scene.add.existing((this as any) as Phaser.GameObjects.GameObject);

Hopefully I can switch those back in a later release.

Try in Phaser v3.54.0.

1 Like

Problem solved. Thanks.