aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-01-29 15:48:16 -0500
committerGitHub <[email protected]>2022-01-29 21:48:16 +0100
commitb5482df6a5083555d6ac0d87de89b0736615c727 (patch)
tree3f7c00304b9df3326631f8cdc4211776b7f57cb1 /src
parent6820a2908e771d5563f55355c819d86b4209855b (diff)
downloadfaker-b5482df6a5083555d6ac0d87de89b0736615c727.tar.xz
faker-b5482df6a5083555d6ac0d87de89b0736615c727.zip
chore: add more type annotations (#358)
Diffstat (limited to 'src')
-rw-r--r--src/address.ts2
-rw-r--r--src/animal.ts28
-rw-r--r--src/date.ts4
-rw-r--r--src/finance.ts8
-rw-r--r--src/helpers.ts8
-rw-r--r--src/internet.ts2
-rw-r--r--src/lorem.ts2
-rw-r--r--src/random.ts4
-rw-r--r--src/system.ts12
9 files changed, 35 insertions, 35 deletions
diff --git a/src/address.ts b/src/address.ts
index d7e878ce..f45bf487 100644
--- a/src/address.ts
+++ b/src/address.ts
@@ -233,7 +233,7 @@ export class Address {
*
* @method faker.address.secondaryAddress
*/
- secondaryAddress() {
+ secondaryAddress(): string {
return this.Helpers.replaceSymbolWithNumber(
this.faker.random.arrayElement(['Apt. ###', 'Suite ###'])
);
diff --git a/src/animal.ts b/src/animal.ts
index 00ca51f5..ac450be8 100644
--- a/src/animal.ts
+++ b/src/animal.ts
@@ -15,7 +15,7 @@ export class Animal {
* Returns a random dog breed.
*
*/
- dog() {
+ dog(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.dog);
}
@@ -23,7 +23,7 @@ export class Animal {
* Returns a random cat breed.
*
*/
- cat() {
+ cat(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.cat);
}
@@ -31,7 +31,7 @@ export class Animal {
* Returns a random snake species.
*
*/
- snake() {
+ snake(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.snake);
}
@@ -39,7 +39,7 @@ export class Animal {
* Returns a random bear species.
*
*/
- bear() {
+ bear(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.bear);
}
@@ -47,7 +47,7 @@ export class Animal {
* Returns a random lion species.
*
*/
- lion() {
+ lion(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.lion);
}
@@ -56,7 +56,7 @@ export class Animal {
*
* @method faker.animal.cetacean
*/
- cetacean() {
+ cetacean(): string {
return this.faker.random.arrayElement(
this.faker.definitions.animal.cetacean
);
@@ -66,7 +66,7 @@ export class Animal {
* Returns a random horse breed.
*
*/
- horse() {
+ horse(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.horse);
}
@@ -74,7 +74,7 @@ export class Animal {
* Returns a random bird species.
*
*/
- bird() {
+ bird(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.bird);
}
@@ -82,7 +82,7 @@ export class Animal {
* Returns a random cow species.
*
*/
- cow() {
+ cow(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.cow);
}
@@ -90,7 +90,7 @@ export class Animal {
* Returns a random fish species.
*
*/
- fish() {
+ fish(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.fish);
}
@@ -98,7 +98,7 @@ export class Animal {
* Returns a random crocodilian species.
*
*/
- crocodilia() {
+ crocodilia(): string {
return this.faker.random.arrayElement(
this.faker.definitions.animal.crocodilia
);
@@ -108,7 +108,7 @@ export class Animal {
* Returns a random insect species.
*
*/
- insect() {
+ insect(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.insect);
}
@@ -116,7 +116,7 @@ export class Animal {
* Returns a random rabbit species
*
*/
- rabbit() {
+ rabbit(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.rabbit);
}
@@ -124,7 +124,7 @@ export class Animal {
* Returns a random animal type.
*
*/
- type() {
+ type(): string {
return this.faker.random.arrayElement(this.faker.definitions.animal.type);
}
}
diff --git a/src/date.ts b/src/date.ts
index 63bcb120..ebde9b7f 100644
--- a/src/date.ts
+++ b/src/date.ts
@@ -159,7 +159,7 @@ export class _Date {
* @method faker.date.month
* @param options
*/
- month(options?: { abbr?: boolean; context?: boolean }) {
+ month(options?: { abbr?: boolean; context?: boolean }): string {
options = options || {};
let type = 'wide';
@@ -185,7 +185,7 @@ export class _Date {
* @method faker.date.weekday
* @param options
*/
- weekday(options?: { abbr?: boolean; context?: boolean }) {
+ weekday(options?: { abbr?: boolean; context?: boolean }): string {
options = options || {};
let type = 'wide';
diff --git a/src/finance.ts b/src/finance.ts
index eff6a13a..2d00570a 100644
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -24,7 +24,7 @@ export class Finance {
* @method faker.finance.account
* @param length
*/
- account(length?: number) {
+ account(length?: number): string {
length ||= 8;
let template = '';
@@ -52,7 +52,7 @@ export class Finance {
*
* @method faker.finance.routingNumber
*/
- routingNumber() {
+ routingNumber(): string {
const routingNumber = this.Helpers.replaceSymbolWithNumber('########');
// Modules 10 straight summation.
@@ -142,7 +142,7 @@ export class Finance {
*
* @method faker.finance.transactionType
*/
- transactionType() {
+ transactionType(): string {
return this.Helpers.randomize(
this.faker.definitions.finance.transaction_type
);
@@ -228,7 +228,7 @@ export class Finance {
* @method faker.finance.creditCardNumber
* @param provider scheme
*/
- creditCardNumber(provider = '') {
+ creditCardNumber(provider = ''): string {
let format: string;
let formats: string | string[];
const localeFormat = this.faker.definitions.finance.credit_card;
diff --git a/src/helpers.ts b/src/helpers.ts
index 3082ace1..3968c221 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -29,7 +29,7 @@ export class Helpers {
* @method faker.helpers.slugify
* @param string
*/
- slugify(string: string = '') {
+ slugify(string: string = ''): string {
return string
.replace(/ /g, '-')
.replace(/[^\一-龠\ぁ-ゔ\ァ-ヴー\w\.\-]+/g, '');
@@ -121,7 +121,7 @@ export class Helpers {
replaceCreditCardSymbols(
string: string = '6453-####-####-####-###L',
symbol: string = '#'
- ) {
+ ): string {
// default values required for calling method without arguments
// Function calculating the Luhn checksum of a number string
@@ -160,7 +160,7 @@ export class Helpers {
* @param string
* @param num
*/
- repeatString(string, num = 0) {
+ repeatString(string, num = 0): string {
let text = '';
for (let i = 0; i < num; i++) {
text += string.toString();
@@ -176,7 +176,7 @@ export class Helpers {
* @method faker.helpers.regexpStyleStringParse
* @param string
*/
- regexpStyleStringParse(string: string = '') {
+ regexpStyleStringParse(string: string = ''): string {
// Deal with range repeat `{min,max}`
const RANGE_REP_REG = /(.)\{(\d+)\,(\d+)\}/;
const REP_REG = /(.)\{(\d+)\}/;
diff --git a/src/internet.ts b/src/internet.ts
index 1fd25046..78a16474 100644
--- a/src/internet.ts
+++ b/src/internet.ts
@@ -401,7 +401,7 @@ export class Internet {
*
* @method faker.internet.userAgent
*/
- userAgent() {
+ userAgent(): string {
return random_ua.generate(this.faker);
}
diff --git a/src/lorem.ts b/src/lorem.ts
index a078e6e0..eb1395f3 100644
--- a/src/lorem.ts
+++ b/src/lorem.ts
@@ -78,7 +78,7 @@ export class Lorem {
* @method faker.lorem.slug
* @param wordCount number of words, defaults to 3
*/
- slug(wordCount?: number) {
+ slug(wordCount?: number): string {
const words = this.faker.lorem.words(wordCount);
return this.Helpers.slugify(words);
}
diff --git a/src/random.ts b/src/random.ts
index 1bd0010b..627e603f 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -233,7 +233,7 @@ export class Random {
* @method faker.random.image
* @deprecated
*/
- image() {
+ image(): string {
console.log(
'Deprecation Warning: faker.random.image is now located in faker.image.image'
);
@@ -397,7 +397,7 @@ export class Random {
* @param count defaults to 1
* @deprecated
*/
- hexaDecimal(count?: number) {
+ hexaDecimal(count?: number): string {
console.log(
'Deprecation Warning: faker.random.hexaDecimal is now located in faker.datatype.hexaDecimal'
);
diff --git a/src/system.ts b/src/system.ts
index 564069f3..063941f0 100644
--- a/src/system.ts
+++ b/src/system.ts
@@ -47,7 +47,7 @@ export class System {
* @example
* faker.system.fileName() // 'self_enabling_accountability_toys.kpt'
*/
- fileName() {
+ fileName(): string {
let str = this.faker.random.words();
str =
str.toLowerCase().replace(/\W/g, '_') + '.' + this.faker.system.fileExt();
@@ -75,7 +75,7 @@ export class System {
* @example
* faker.system.mimeType() // 'video/vnd.vivo'
*/
- mimeType() {
+ mimeType(): string {
const typeSet = new Set<string>();
const extensionSet = new Set();
const mimeTypes = this.faker.definitions.system.mimeTypes;
@@ -105,7 +105,7 @@ export class System {
* @example
* faker.system.commonFileType() // 'audio'
*/
- commonFileType() {
+ commonFileType(): string {
return this.faker.random.arrayElement(commonFileTypes);
}
@@ -115,7 +115,7 @@ export class System {
* @example
* faker.system.commonFileExt() // 'gif'
*/
- commonFileExt() {
+ commonFileExt(): string {
return this.faker.system.fileExt(
this.faker.random.arrayElement(commonMimeTypes)
);
@@ -127,7 +127,7 @@ export class System {
* @example
* faker.system.fileType() // 'message'
*/
- fileType() {
+ fileType(): string {
const typeSet = new Set<string>();
const extensionSet = new Set();
const mimeTypes = this.faker.definitions.system.mimeTypes;
@@ -205,7 +205,7 @@ export class System {
* @example
* faker.system.filePath() // '/usr/local/src/money.rmp.dotx'
*/
- filePath() {
+ filePath(): string {
return this.faker.fake(
'{{system.directoryPath}}/{{system.fileName}}.{{system.fileExt}}'
);