Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

389
Visualizações
Typescript an argument was not provided

I'm trying to implement inheritance in a game I'm making with typescript (pixi.js) but I'm getting stuck on this error. I have a class, Dog, with the following code:

export class Dog extends Enemy {
  //private game: Game;
  //private speed: number = 0;

  constructor(texture: PIXI.Texture, game: Game) {
    super(texture);
    this.game = game;

  }

I also have a class enemy, which the class dog extends to, with the following code:

export class Enemy extends PIXI.Sprite {
  public game: Game;
  public speed: number = 0;

  constructor(texture: PIXI.Texture, game: Game) {
    super(texture);
    this.game = game;
  }

But in my dog.ts file I get the following error under the super(texture); part of my code: Expected 2 arguments, but got 1.ts(2554) enemy.ts(8, 38): An argument for 'game' was not provided.

I have no idea what this means as I would expect I have given an argument for the game in enemy.ts and I also extend to Pixi.sprite.

Edit: If I change the super in enemy.ts to super(texture, game) I get the following error: if I do this I get the following error: Expected 0-1 arguments, but got 2.ts(2554)

I can only put on argument in the super function so I'm afraid this won't fix the problem

Edit 2: Nvm I changed the wrong file

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

Because you did not provide game (which is a required argument) in super. In the Dog class add game parameter to the super function:

super(texture, game);
about 4 years ago · Santiago Gelvez Relatório

0

Well, the constructor of Enemy expects two arguments in input: texture: PIXI.Texture, game: Game but you are giving only the first one.

So, in your dog.ts from

super(texture)

Modify to

super(texture, game)

The same error may appear in Enemy class if the Pixi.Sprite expects the same two arguments.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda