`TweenManager.create` and similar functions take overly permissive `object` config types
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 40.3k
- Forks
- 7.2k
- PR merge metrics
- No merged PRs in 30d
Description
Version
- Phaser Version: 3.90
- Operating system: Ubuntu 24.04 LTS (irrelevant)
- Browser: N/A
Description
The types of TweenManager.chain, TweenManager.create and TweenManager.addMultiple all include object and/or object[] in the allowed type signature for their config parameters.
This means you can pass ANYTHING shaped like an object to these functions, even ones that almost certainly do not work as expected.
Example Test Code
This code typechecks correctly, despite passing configs that do not align with Phaser's expectations:
// these are technically objects, though unexpected and very much invalid
game.scene.tweens.create([1]);
game.scene.tweens.chain({});
Additional Information
From what I can tell, the unions were added in "Extra properties for tween configs" from 2019, which (presumably) was done so you could add extra props to the tween configs without issue.
However, since all of the relevant config types now have [key: string]: any index signatures that allow extra properties anyways, these methods don't need to allow passing object anymore (and makes writing external wrappers for said methods difficult).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the type declarations or definitions for TweenManager.chain, TweenManager.create, and TweenManager.addMultiple, then reproduce the TypeScript examples from the issue. Check that valid tween configuration types still work while the shown array and empty-object configurations are rejected. Done means those three config signatures no longer accept bare object or object[] types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100