Skip to content

Commit

Permalink
chore: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 11, 2022
1 parent 8a4bc66 commit b22cc32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = string>(array?: T[]): T {
array ||= ['a', 'b', 'c'] as unknown as T[];
const r = this.faker.datatype.number({ max: array.length - 1 });
return array[r];
}
}

0 comments on commit b22cc32

Please sign in to comment.