diff --git a/src/math/random-data-generator/RandomDataGenerator.js b/src/math/random-data-generator/RandomDataGenerator.js index 25a1236a82..c0acf74686 100644 --- a/src/math/random-data-generator/RandomDataGenerator.js +++ b/src/math/random-data-generator/RandomDataGenerator.js @@ -349,10 +349,10 @@ var RandomDataGenerator = new Class({ * @since 3.0.0 * * @generic T - * @genericUse {T[]} - [array] + * @genericUse {ArrayLike} - [array] * @genericUse {T} - [$return] * - * @param {T[]} array - The array to pick a random element from. + * @param {ArrayLike} array - The array (or array-like object) to pick a random element from. * * @return {T} A random member of the array. */ @@ -370,6 +370,8 @@ var RandomDataGenerator = new Class({ * * @return {number} -1 or +1. */ + // NB: Catharsis (the underlying parser used by JSDoc) does not support parsing negative numbers inside types. + // Moreover, the `jsdoc` package used for typegen is (effectively) unmaintained, preventing us from typing this as `-1 | 1`. sign: function () { return this.pick(this.signs); @@ -382,10 +384,10 @@ var RandomDataGenerator = new Class({ * @since 3.0.0 * * @generic T - * @genericUse {T[]} - [array] + * @genericUse {ArrayLike} - [array] * @genericUse {T} - [$return] * - * @param {T[]} array - The array to pick a random element from. + * @param {ArrayLike} array - The array (or array-like object) to pick a random element from. * * @return {T} A random member of the array. */ diff --git a/types/phaser.d.ts b/types/phaser.d.ts index 62345ca813..b976644eea 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -90353,10 +90353,10 @@ declare namespace Phaser { /** * Returns a random element from within the given array. - * @param array The array to pick a random element from. + * @param array The array (or array-like object) to pick a random element from. * @returns A random member of the array. */ - pick(array: T[]): T; + pick(array: ArrayLike): T; /** * Returns a randomly selected sign value, either -1 or +1. Useful for multiplying a value @@ -90367,10 +90367,10 @@ declare namespace Phaser { /** * Returns a random element from within the given array, favoring the earlier entries. - * @param array The array to pick a random element from. + * @param array The array (or array-like object) to pick a random element from. * @returns A random member of the array. */ - weightedPick(array: T[]): T; + weightedPick(array: ArrayLike): T; /** * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. @@ -130528,7 +130528,8 @@ declare namespace Phaser { * @param y The y coordinate of the pixel within the Texture. * @param key The unique string-based key of the Texture. * @param frame The string or index of the Frame. - * @returns A Color object populated with the color values of the requested pixel, or `null` if the coordinates were out of bounds. + * @returns A Color object populated with the color values of the requested pixel, + * or `null` if the coordinates were out of bounds. */ getPixel(x: number, y: number, key: string, frame?: string | number): Phaser.Display.Color | null; @@ -131924,7 +131925,8 @@ declare namespace Phaser { * GID this set will use here. Default 0. * @param tileOffset Tile texture drawing offset. * If not specified, it will default to {0, 0} Default {x: 0, y: 0}. - * @returns Returns the Tileset object that was created or updated, or null if it failed. + * @returns Returns the Tileset object that was created or updated, or null if it + * failed. */ addTilesetImage(tilesetName: string, key?: string, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number, tileOffset?: object): Phaser.Tilemaps.Tileset | null; @@ -137833,7 +137835,8 @@ declare namespace Phaser { * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. * Returns null if tile index is not contained in this Tileset. * @param tileIndex The unique id of the tile across all tilesets in the map. - * @returns Object in the form { x, y } representing the top-left UV coordinate within the Tileset image. + * @returns Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. */ getTileTextureCoordinates(tileIndex: number): object | null; @@ -139243,7 +139246,8 @@ declare namespace Phaser { * @param insertNull Controls how empty tiles (those with an index of -1) are stored in * the LayerData. If `true`, empty tile positions are stored as `null`. If `false`, a Tile object * with an index of -1 is created for each empty position instead. - * @returns - An array of LayerData objects, one for each entry in json.layer. + * @returns - An array of LayerData objects, one for each entry in + * json.layer. */ function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; @@ -139412,7 +139416,8 @@ declare namespace Phaser { * @param json The Tiled JSON object. * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). - * @returns - An array of LayerData objects, one for each entry in json.layers with the type 'tilelayer'. + * @returns - An array of LayerData objects, one for each entry in + * json.layers with the type 'tilelayer'. */ function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[];