Skip to content

TweenManager.create and similar functions take overly permissive object config types #7260

@Bertie690

Description

@Bertie690

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions