phaserjs / phaserjs/phaser

[Types]: TweenChain.remove() issues an error with 1 argument.

Open
#7,131 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

When using the TweenChain.remove() method with an argument, the TypeScript compiler issues an error:

src/scenes/PlayScene.ts:481:46 - error TS2554: Expected 0 arguments, but got 1.

481             this.finalScoreAnimation?.remove(tween);

Even though the finalScoreAnimation property is recognized as a TweenChain but the remove() method is typed as BaseTween.remove(). This might be an issue with how the tsgen script handles overrides.

https://github.com/phaserjs/phaser/blob/c62baca677399e098ce21bb49757974c4742895b/src/tweens/tween/TweenChain.js#L155

When thinking about it a little more, the change from a 0 argument method to a 1 argument method in the child class doesn't really comply with the Liskov Substitution Principle (it doesn't event have the same effect). Maybe renaming this method to something like removeTween() would make more sense?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TweenChain.js implementation around line 155 and inspect how the tsgen script represents the overridden remove() method. Resolve whether the generated TypeScript declaration should accept a tween or whether the API needs a distinct name, then verify that the PlayScene.ts call type-checks and the resulting public API is consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.