Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

387
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!