mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Fix types for pickRandom
The TS type for pickRandom currently restricts the given array to numbers, however (AFAIK) it doesn't actually care what the array given to it contains. This PR: - Uses a generic to type the given array - Varies the return type (T or T[]) depending on the given args
This commit is contained in:
parent
dbfce94f7a
commit
b2e83e6bd7
9
types/index.d.ts
vendored
9
types/index.d.ts
vendored
@ -2203,11 +2203,10 @@ declare namespace math {
|
||||
* undefined. Returns an array with the configured number of elements
|
||||
* when number is > 1.
|
||||
*/
|
||||
pickRandom(
|
||||
array: number[],
|
||||
number?: number,
|
||||
weights?: number[]
|
||||
): number | number[]
|
||||
pickRandom<T>(array: T[]): T
|
||||
pickRandom<T>(array: T[], number: 1, weights?: number[]): T
|
||||
pickRandom<T>(array: T[], number: number): T[]
|
||||
pickRandom<T>(array: T[], number: number, weights: number[]): T[]
|
||||
|
||||
/**
|
||||
* Return a random number larger or equal to min and smaller than max
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user