Types: Narrow Tween configuration inputs - #7375
Open
bagel786 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟡 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 oldobject-permissivecreate,addMultiple, andchainsignatures. On a clean checkout the new object-based@ts-expect-errorcases (create({ unexpected: true })andchain({})) 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
tweensrequired narrows valid chain configurations such as{ delay: 100 }or{ targets: sprite }, even thoughTweenChainBuilderexplicitly accepts configs without atweensarray (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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR
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 tsgennpm run test-tsnpx vitest run tests/tweens/builders/TweenBuilder.test.js tests/tweens/builders/TweenChainBuilder.test.jsFixes #7260