Version
- Phaser Version: 3.90.0
- Operating system: Ubuntu 24.04 LTS (irrelevant)
Description
Currently, Phaser.Math.RandomDataGenerator.Pick and its weighted counterpart require the arguments passed in to be mutable arrays.
Since these functions do not mutate their arguments[^1] (and, moreover, do not require anything but numeric indexes and a .length property), they should use the ArrayLike<T> interface instead.
At the moment, attempting to pass in readonly arrays (or array-like objects such as TypedArray) will produce type errors despite working perfectly well at runtime.
Example Test Code
import Phaser from "phaser";
const nums = [1, 2, 3] as const;
const randomNum = Phaser.Math.RND.pick(nums);
// type errors since `nums` is readonly, despite running perfectly fine
Additional Information
Trivial to fix; I will create a PR shortly.