Extending an extended class (this time in TS)

hi guys, yesterday I asked about how to extend a class of an extended class. thanks @samme for the help again.

Today I decided to move my game from JS to Typescript cause I feel pretty lost with no autocomplete/intellisense and it’s nice to have some context with the mousehover, so now Im using TS for the first time and I must say, that I like it a lot so far. My problem though is that I get errors that werent there in the JS version…

this is the extended class that I want to extend further:

class Menu extends Phaser.GameObjects.Container {
    menuItems: any[];
    menuItemIndex: number;
    heroes: any;
    constructor(x: number, y: number, scene: Phaser.Scene, heroes: any) {
        super(scene, x, y, heroes);
        this.menuItems = [];
        this.menuItemIndex = 0;
        this.heroes = heroes;
        this.x = x;
        this.y = y;
    }

and this is the extended class

class HeroesMenu extends Menu {
    constructor(x: number, y: number, scene: Phaser.Scene) {
        super(x, y, scene);
    }
}

the scene in the super of this class is underlined in red, telling me:

“Expected 4 arguments, but got 3.ts(2554)
game.ts(22, 60): An argument for ‘heroes’ was not provided.”

any idea what that means?

thanks!

You need to mark that argument optional, heroes?: any.

1 Like

wow, so easy, yet so hard to know. thanks once again @samme!