Skip to content

Update pick/weightedPick typings to accept array-like objects#7258

Open
Bertie690 wants to merge 4 commits into
phaserjs:masterfrom
Bertie690:pick-types
Open

Update pick/weightedPick typings to accept array-like objects#7258
Bertie690 wants to merge 4 commits into
phaserjs:masterfrom
Bertie690:pick-types

Conversation

@Bertie690
Copy link
Copy Markdown

@Bertie690 Bertie690 commented Feb 27, 2026

Fixes #7257

This PR:

  • Fixes a bug

Describe the changes below:

Updated typings of relevant methods to allow passing in array-like objects like TypedArray and readonly arrays. (At runtime, all we require is a numeric length and numeric index support, so array-like objects work just fine here.)


Note

Medium Risk
TypeScript declaration changes affect public API typings for RandomDataGenerator; while runtime behavior is unchanged, the updated signatures (and the sign() typing/doc change) could impact downstream TS compile behavior and type safety.

Overview
Updates RandomDataGenerator pick and weightedPick to be documented/typed as accepting ArrayLike<T> (e.g., typed arrays/readonly arrays) instead of only T[].

Also adjusts return typing/docs for sign() in JS docs (to -1 | 1) and in types/phaser.d.ts (now sign(): any with an updated @returns), plus a few minor @returns doc formatting tweaks elsewhere in the d.ts file.

Reviewed by Cursor Bugbot for commit 126152d. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 126152d. Configure here.

Comment thread types/phaser.d.ts Outdated
@cursor
Copy link
Copy Markdown

cursor Bot commented May 7, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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.

Phaser.Math.RND.Pick and Phaser.Math.RND.WeightedPick should use ArrayLike interface

1 participant