Skip to content

Types: Narrow Tween configuration inputs - #7375

Open
bagel786 wants to merge 2 commits into
phaserjs:masterfrom
bagel786:fix/tween-manager-config-types
Open

bagel786 wants to merge 2 commits into
phaserjs:masterfrom
bagel786:fix/tween-manager-config-types

Conversation

@bagel786

@bagel786 bagel786 commented Sep 11, 2026 •

Copy link
Copy Markdown

Narrows Tween/chain APIs to supported config and instance types. Preserves optional chain tweens and targets for empty/delayed chains, includes runtime repeat aliases, and rejects invalid primitive/array inputs. Chain config exposes its supported options; custom Tween target properties remain supported.

Includes the affected published types/phaser.d.ts declarations, preserving unrelated generated ordering instead of including generator-wide churn. Type fixtures compile against the checked-in published artifact.

Fixes #7260. Continues #7359.

Validation: declaration generation and published-artifact TypeScript checks pass; 360 builder tests pass; changed source passes compatible ESLint. The shared full runtime suite has four baseline BaseTween countdown failures (23,321 passed, 4 todo).

Copilot AI lite review requested due to automatic review settings September 11, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Regenerated TypeScript declarations are missing, and the chain configuration type incorrectly makes tweens required.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR narrows Tween and Tween Chain configuration types while preserving custom properties and target inheritance.

Changes:

  • Refines Tween and Tween Chain JSDoc signatures.
  • Updates builder and manager API types.
  • Adds TypeScript acceptance and rejection cases.
File summaries
File Description
src/tweens/typedefs/TweenChainBuilderConfig.js Refines chain configuration properties.
src/tweens/TweenManager.js Narrows manager API types.
src/tweens/tween/TweenChain.js Updates chain API documentation.
src/tweens/builders/TweenChainBuilder.js Narrows chain builder inputs.
src/tweens/builders/TweenBuilder.js Narrows Tween builder inputs.
scripts/tsgen/test/src/game.ts Adds TypeScript validation cases.
Review details

Suppressed comments (2)

scripts/tsgen/test/src/game.ts:388

  • The TypeScript fixture compiles against types/phaser.d.ts (scripts/tsgen/test/tsconfig.json:22), but that declaration still has the old object-permissive create, addMultiple, and chain signatures. On a clean checkout the new object-based @ts-expect-error cases (create({ unexpected: true }) and chain({})) are unused, while consumers still receive the old API; regenerate and include the declaration output with these JSDoc changes.
        // @ts-expect-error Arbitrary objects are not Tween configuration objects
        this.tweens.create({ unexpected: true });

        // @ts-expect-error Tween chain configurations require the typed config shape
        this.tweens.chain({});

src/tweens/typedefs/TweenChainBuilderConfig.js:12

  • Making tweens required narrows valid chain configurations such as { delay: 100 } or { targets: sprite }, even though TweenChainBuilder explicitly accepts configs without a tweens array (GetValue(..., null)) and the property was previously documented as optional. This prevents creating an empty/configured chain and adding its tweens later; preserve the optional runtime-supported shape while using a separate non-empty constraint if rejecting {} is required.
 * @property {Array.<(Partial.<Phaser.Types.Tweens.TweenBuilderConfig>|Phaser.Tweens.Tween)>} tweens - The tweens to chain together. Each Tween configuration can inherit targets from this Tween Chain.
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

* @since 3.0.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenBuilderConfig[]|object|object[]} config - A Tween Configuration object. Or an array of Tween Configuration objects.
* @param {Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain|Array.<(Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} config - A Tween Configuration object, a Tween or TweenChain instance, or an array of them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants