Skip to content

Commit f3350ce

Browse files
committed
TypeScript: improve pick/shuffle types
1 parent 4f8dd24 commit f3350ce

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/math/random-data-generator/RandomDataGenerator.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,14 @@ var RandomDataGenerator = new Class({
347347
*
348348
* @method Phaser.Math.RandomDataGenerator#pick
349349
* @since 3.0.0
350+
*
351+
* @generic T
352+
* @genericUse {T[]} - [array]
353+
* @genericUse {T} - [$return]
350354
*
351-
* @param {array} array - The array to pick a random element from.
355+
* @param {T[]} array - The array to pick a random element from.
352356
*
353-
* @return {*} A random member of the array.
357+
* @return {T} A random member of the array.
354358
*/
355359
pick: function (array)
356360
{
@@ -376,9 +380,13 @@ var RandomDataGenerator = new Class({
376380
* @method Phaser.Math.RandomDataGenerator#weightedPick
377381
* @since 3.0.0
378382
*
379-
* @param {array} array - The array to pick a random element from.
383+
* @generic T
384+
* @genericUse {T[]} - [array]
385+
* @genericUse {T} - [$return]
380386
*
381-
* @return {*} A random member of the array.
387+
* @param {T[]} array - The array to pick a random element from.
388+
*
389+
* @return {T} A random member of the array.
382390
*/
383391
weightedPick: function (array)
384392
{
@@ -468,9 +476,12 @@ var RandomDataGenerator = new Class({
468476
* @method Phaser.Math.RandomDataGenerator#shuffle
469477
* @since 3.7.0
470478
*
471-
* @param {array} [array] - The array to be shuffled.
479+
* @generic T
480+
* @genericUse {T[]} - [array,$return]
481+
*
482+
* @param {T[]} [array] - The array to be shuffled.
472483
*
473-
* @return {array} The shuffled array.
484+
* @return {T[]} The shuffled array.
474485
*/
475486
shuffle: function (array)
476487
{

src/utils/array/Shuffle.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
* @function Phaser.Utils.Array.Shuffle
1313
* @since 3.0.0
1414
*
15-
* @param {array} array - The array to shuffle. This array is modified in place.
15+
* @generic T
16+
* @genericUse {T[]} - [array,$return]
1617
*
17-
* @return {array} The shuffled array.
18+
* @param {T[]} array - The array to shuffle. This array is modified in place.
19+
*
20+
* @return {T[]} The shuffled array.
1821
*/
1922
var Shuffle = function (array)
2023
{

0 commit comments

Comments
 (0)