Skip to content

Types: Narrow Tween configuration inputs - #7375

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

Types: Narrow Tween configuration inputs#7375
bagel786 wants to merge 1 commit into
phaserjs:masterfrom
bagel786:fix/tween-manager-config-types

Conversation

@bagel786

Copy link
Copy Markdown

This PR

  • Fixes a bug

Replace broad object fallbacks with the explicit Tween config and instance types supported at runtime. Keep custom properties and Tween Chain target inheritance while rejecting invalid primitive and arbitrary-object inputs.

Tests:

  • npm run tsgen
  • npm run test-ts
  • npx vitest run tests/tweens/builders/TweenBuilder.test.js tests/tweens/builders/TweenChainBuilder.test.js

Fixes #7260


Continues #7359 — the fork repo backing that PR was accidentally deleted from this account, and GitHub blocks reopening a PR whose submitting repository was deleted (a restore request is being filed with GitHub Support). This PR resumes the identical work from the same commit (78edab7e09161b3c147a0abdf7af4d22d24e2853); review discussion continues on the original PR.

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