aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/airline/index.ts4
-rw-r--r--src/modules/animal/index.ts4
-rw-r--r--src/modules/color/index.ts4
-rw-r--r--src/modules/commerce/index.ts4
-rw-r--r--src/modules/company/index.ts4
-rw-r--r--src/modules/database/index.ts4
-rw-r--r--src/modules/datatype/index.ts4
-rw-r--r--src/modules/date/index.ts4
-rw-r--r--src/modules/finance/index.ts4
-rw-r--r--src/modules/git/index.ts4
-rw-r--r--src/modules/hacker/index.ts4
-rw-r--r--src/modules/helpers/index.ts18
-rw-r--r--src/modules/helpers/unique.ts8
-rw-r--r--src/modules/image/index.ts8
-rw-r--r--src/modules/image/providers/placeholder.ts4
-rw-r--r--src/modules/internet/index.ts4
-rw-r--r--src/modules/location/index.ts4
-rw-r--r--src/modules/lorem/index.ts4
-rw-r--r--src/modules/music/index.ts4
-rw-r--r--src/modules/number/index.ts4
-rw-r--r--src/modules/person/index.ts4
-rw-r--r--src/modules/phone/index.ts4
-rw-r--r--src/modules/random/index.ts4
-rw-r--r--src/modules/science/index.ts4
-rw-r--r--src/modules/string/index.ts4
-rw-r--r--src/modules/system/index.ts4
-rw-r--r--src/modules/vehicle/index.ts4
-rw-r--r--src/modules/word/index.ts4
28 files changed, 102 insertions, 32 deletions
diff --git a/src/modules/airline/index.ts b/src/modules/airline/index.ts
index 3a5a400c..aeeb4873 100644
--- a/src/modules/airline/index.ts
+++ b/src/modules/airline/index.ts
@@ -66,7 +66,9 @@ const aircraftTypeSeats: Record<AircraftType, string[]> = {
export class AirlineModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(AirlineModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ AirlineModule.prototype
+ ) as Array<keyof AirlineModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/animal/index.ts b/src/modules/animal/index.ts
index 3cd9d71e..90efc7ab 100644
--- a/src/modules/animal/index.ts
+++ b/src/modules/animal/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class AnimalModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(AnimalModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ AnimalModule.prototype
+ ) as Array<keyof AnimalModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/color/index.ts b/src/modules/color/index.ts
index 981dae60..67fa9b9a 100644
--- a/src/modules/color/index.ts
+++ b/src/modules/color/index.ts
@@ -160,7 +160,9 @@ function toColorFormat(
export class ColorModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(ColorModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ ColorModule.prototype
+ ) as Array<keyof ColorModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/commerce/index.ts b/src/modules/commerce/index.ts
index 66f6d02c..54d2bce1 100644
--- a/src/modules/commerce/index.ts
+++ b/src/modules/commerce/index.ts
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
export class CommerceModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(CommerceModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ CommerceModule.prototype
+ ) as Array<keyof CommerceModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/company/index.ts b/src/modules/company/index.ts
index 79f2fa8f..467256c7 100644
--- a/src/modules/company/index.ts
+++ b/src/modules/company/index.ts
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
export class CompanyModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(CompanyModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ CompanyModule.prototype
+ ) as Array<keyof CompanyModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/database/index.ts b/src/modules/database/index.ts
index 922f4b0e..88a7609a 100644
--- a/src/modules/database/index.ts
+++ b/src/modules/database/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class DatabaseModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(DatabaseModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ DatabaseModule.prototype
+ ) as Array<keyof DatabaseModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/datatype/index.ts b/src/modules/datatype/index.ts
index 25235bb5..7410e149 100644
--- a/src/modules/datatype/index.ts
+++ b/src/modules/datatype/index.ts
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
export class DatatypeModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(DatatypeModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ DatatypeModule.prototype
+ ) as Array<keyof DatatypeModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index c99a7d19..d7a0f12a 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -28,7 +28,9 @@ function toDate(
export class DateModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(DateModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ DateModule.prototype
+ ) as Array<keyof DateModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts
index d137ee1b..8db5bfce 100644
--- a/src/modules/finance/index.ts
+++ b/src/modules/finance/index.ts
@@ -8,7 +8,9 @@ import iban from './iban';
export class FinanceModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(FinanceModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ FinanceModule.prototype
+ ) as Array<keyof FinanceModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/git/index.ts b/src/modules/git/index.ts
index 394f9610..5a963840 100644
--- a/src/modules/git/index.ts
+++ b/src/modules/git/index.ts
@@ -24,7 +24,9 @@ const GIT_TIMEZONE_FORMAT = new Intl.NumberFormat('en', {
export class GitModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(GitModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(GitModule.prototype) as Array<
+ keyof GitModule | 'constructor'
+ >) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/hacker/index.ts b/src/modules/hacker/index.ts
index aadf839a..00b9a686 100644
--- a/src/modules/hacker/index.ts
+++ b/src/modules/hacker/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class HackerModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(HackerModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ HackerModule.prototype
+ ) as Array<keyof HackerModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index c22a3612..55732f4a 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -10,7 +10,9 @@ import * as uniqueExec from './unique';
export class HelpersModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(HelpersModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ HelpersModule.prototype
+ ) as Array<keyof HelpersModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
@@ -804,8 +806,10 @@ export class HelpersModule {
// Search for the requested method or definition
for (const part of parts) {
- currentModuleOrMethod = currentModuleOrMethod?.[part];
- currentDefinitions = currentDefinitions?.[part];
+ currentModuleOrMethod =
+ currentModuleOrMethod?.[part as keyof typeof currentModuleOrMethod];
+ currentDefinitions =
+ currentDefinitions?.[part as keyof typeof currentDefinitions];
}
// Make method executable
@@ -903,7 +907,13 @@ export class HelpersModule {
*
* @since 7.5.0
*/
- unique<Method extends (...parameters) => RecordKey>(
+ unique<
+ Method extends (
+ // TODO christopher 2023-02-14: This `any` type can be fixed by anyone if they want to.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ...parameters: any[]
+ ) => RecordKey
+ >(
method: Method,
args?: Parameters<Method>,
options: {
diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts
index fd240c2f..ebd1b88e 100644
--- a/src/modules/helpers/unique.ts
+++ b/src/modules/helpers/unique.ts
@@ -81,7 +81,13 @@ Try adjusting maxTime or maxRetries parameters for faker.helpers.unique().`
* @param options.compare The function used to determine whether a value was already returned. Defaults to check the existence of the key.
* @param options.store The store of unique entries. Defaults to `GLOBAL_UNIQUE_STORE`.
*/
-export function exec<Method extends (...parameters) => RecordKey>(
+export function exec<
+ Method extends (
+ // TODO christopher 2023-02-14: This `any` type can be fixed by anyone if they want to.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ...parameters: any[]
+ ) => RecordKey
+>(
method: Method,
args: Parameters<Method>,
options: {
diff --git a/src/modules/image/index.ts b/src/modules/image/index.ts
index 794a9514..ac42dc25 100644
--- a/src/modules/image/index.ts
+++ b/src/modules/image/index.ts
@@ -26,12 +26,16 @@ export class ImageModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(ImageModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ ImageModule.prototype
+ ) as Array<keyof ImageModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
- this[name] = this[name].bind(this);
+ this[name] =
+ // @ts-expect-error: remove this expect-error when we remove the deprecated sub-modules
+ this[name].bind(this);
}
this.unsplash = new Unsplash(this.faker);
diff --git a/src/modules/image/providers/placeholder.ts b/src/modules/image/providers/placeholder.ts
index 9691a9ff..0101e681 100644
--- a/src/modules/image/providers/placeholder.ts
+++ b/src/modules/image/providers/placeholder.ts
@@ -9,7 +9,9 @@ import { deprecated } from '../../../internal/deprecated';
export class Placeholder {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(Placeholder.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ Placeholder.prototype
+ ) as Array<keyof Placeholder | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts
index 3287e404..2623f8b3 100644
--- a/src/modules/internet/index.ts
+++ b/src/modules/internet/index.ts
@@ -29,7 +29,9 @@ export type HTTPProtocolType = 'http' | 'https';
export class InternetModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(InternetModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ InternetModule.prototype
+ ) as Array<keyof InternetModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts
index 5fe542cb..4ce28bcf 100644
--- a/src/modules/location/index.ts
+++ b/src/modules/location/index.ts
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
export class LocationModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(LocationModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ LocationModule.prototype
+ ) as Array<keyof LocationModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/lorem/index.ts b/src/modules/lorem/index.ts
index 9c9b514f..4e124929 100644
--- a/src/modules/lorem/index.ts
+++ b/src/modules/lorem/index.ts
@@ -7,7 +7,9 @@ import { filterWordListByLength } from '../word/filterWordListByLength';
export class LoremModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(LoremModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ LoremModule.prototype
+ ) as Array<keyof LoremModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/music/index.ts b/src/modules/music/index.ts
index e25ade68..15d282d4 100644
--- a/src/modules/music/index.ts
+++ b/src/modules/music/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class MusicModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(MusicModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ MusicModule.prototype
+ ) as Array<keyof MusicModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/number/index.ts b/src/modules/number/index.ts
index 96e5067d..3cd35f40 100644
--- a/src/modules/number/index.ts
+++ b/src/modules/number/index.ts
@@ -8,7 +8,9 @@ import type { Mersenne } from '../../internal/mersenne/mersenne';
export class NumberModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(NumberModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ NumberModule.prototype
+ ) as Array<keyof NumberModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/person/index.ts b/src/modules/person/index.ts
index da30fee7..ccbb8e14 100644
--- a/src/modules/person/index.ts
+++ b/src/modules/person/index.ts
@@ -61,7 +61,9 @@ function selectDefinition(
export class PersonModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(PersonModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ PersonModule.prototype
+ ) as Array<keyof PersonModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/phone/index.ts b/src/modules/phone/index.ts
index 437464bf..d604c44a 100644
--- a/src/modules/phone/index.ts
+++ b/src/modules/phone/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class PhoneModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(PhoneModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ PhoneModule.prototype
+ ) as Array<keyof PhoneModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts
index 4936fe80..c12df82d 100644
--- a/src/modules/random/index.ts
+++ b/src/modules/random/index.ts
@@ -14,7 +14,9 @@ import type {
export class RandomModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(RandomModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ RandomModule.prototype
+ ) as Array<keyof RandomModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/science/index.ts b/src/modules/science/index.ts
index 7dba5d3d..754bcbdf 100644
--- a/src/modules/science/index.ts
+++ b/src/modules/science/index.ts
@@ -35,7 +35,9 @@ export interface Unit {
export class ScienceModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(ScienceModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ ScienceModule.prototype
+ ) as Array<keyof ScienceModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts
index 188c91eb..f6180df3 100644
--- a/src/modules/string/index.ts
+++ b/src/modules/string/index.ts
@@ -91,7 +91,9 @@ const SAMPLE_MAX_LENGTH = 2 ** 20;
export class StringModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(StringModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ StringModule.prototype
+ ) as Array<keyof StringModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/system/index.ts b/src/modules/system/index.ts
index 2f3ce371..35ca2c8d 100644
--- a/src/modules/system/index.ts
+++ b/src/modules/system/index.ts
@@ -38,7 +38,9 @@ const CRON_DAY_OF_WEEK = [
export class SystemModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(SystemModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ SystemModule.prototype
+ ) as Array<keyof SystemModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/vehicle/index.ts b/src/modules/vehicle/index.ts
index 9c9841b0..2b153c79 100644
--- a/src/modules/vehicle/index.ts
+++ b/src/modules/vehicle/index.ts
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
export class VehicleModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(VehicleModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ VehicleModule.prototype
+ ) as Array<keyof VehicleModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
diff --git a/src/modules/word/index.ts b/src/modules/word/index.ts
index 5548e74f..614c6a59 100644
--- a/src/modules/word/index.ts
+++ b/src/modules/word/index.ts
@@ -8,7 +8,9 @@ import { filterWordListByLength } from './filterWordListByLength';
export class WordModule {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(WordModule.prototype)) {
+ for (const name of Object.getOwnPropertyNames(
+ WordModule.prototype
+ ) as Array<keyof WordModule | 'constructor'>) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}