-
Notifications
You must be signed in to change notification settings - Fork 7.1k
TypeScript compiler error when adding a layer to a layer #5459
Copy link
Copy link
Closed
Labels
Description
Version
- Phaser Version: 3.50.0
- Operating system: Linux
- TypeScript: 4.0.5
Description
The Phaser.GameObjects.Layer class doesn't extend Phaser.GameObjects.GameObject and it creates TypeScript compiler errors.
Example Test Code
class DemoLayer extends Phaser.Scene {
create() {
const layer1 = this.add.layer();
const layer2 = this.add.layer();
layer1.add(layer2); // error, GameObject expected
this.sys.displayList.add(layer1); // error, GameObject expected
this.add.existing(layer1); // error, GameObject expected
}
}Additional Information
You can test this project:
Unzip it and run:
$ cd LayerCompilerError
$ tscYou will get the following errors:
main.ts:9:14 - error TS2345: Argument of type 'Layer' is not assignable to parameter of type 'GameObject'.
Type 'Layer' is missing the following properties from type 'GameObject': parentContainer, tabIndex, input, body, and 14 more.
9 layer1.add(layer2);
~~~~~~
main.ts:11:28 - error TS2345: Argument of type 'Layer' is not assignable to parameter of type 'GameObject'.
11 this.sys.displayList.add(layer1);
~~~~~~
main.ts:13:21 - error TS2345: Argument of type 'Layer' is not assignable to parameter of type 'GameObject'.
13 this.add.existing(layer1);
~~~~~~
Found 3 errors.
Reactions are currently unavailable