diff --git a/src/helpers.ts b/src/helpers.ts index f8219b3544d..c3a849d6a18 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -17,7 +17,7 @@ export class Helpers { * @method faker.helpers.randomize * @param array */ - randomize(array: T[] = ['a', 'b', 'c'] as unknown as T[]): T { + randomize(array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray): T { return this.faker.random.arrayElement(array); } diff --git a/src/random.ts b/src/random.ts index d460b4e36ca..8414134a84a 100644 --- a/src/random.ts +++ b/src/random.ts @@ -72,7 +72,7 @@ export class Random { * @method faker.random.arrayElement * @param array */ - arrayElement(array: T[] = ['a', 'b', 'c'] as unknown as T[]): T { + arrayElement(array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray): T { const r = this.faker.datatype.number({ max: array.length - 1 }); return array[r]; } @@ -85,7 +85,7 @@ export class Random { * @param count number of elements to pick */ arrayElements( - array: T[] = ['a', 'b', 'c'] as unknown as T[], + array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray, count?: number ): T[] { if (typeof count !== 'number') {