diff --git a/src/random.ts b/src/random.ts index 8b4feb29758..a0dece32107 100644 --- a/src/random.ts +++ b/src/random.ts @@ -16,9 +16,9 @@ export class Random { * @method faker.random.arrayElement * @param array */ - arrayElement(array) { - array = array || ['a', 'b', 'c']; - var r = this.faker.datatype.number({ max: array.length - 1 }); + arrayElement(array?: T[]): T { + array ||= ['a', 'b', 'c'] as unknown as T[]; + const r = this.faker.datatype.number({ max: array.length - 1 }); return array[r]; } }