Skip to content

Commit c1b15c5

Browse files
authored
Merge branch 'next' into 1841-birthday-error-message
2 parents 212daad + e7230f6 commit c1b15c5

File tree

31 files changed

+112
-36
lines changed

31 files changed

+112
-36
lines changed

src/modules/airline/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ const aircraftTypeSeats: Record<AircraftType, string[]> = {
6666
export class AirlineModule {
6767
constructor(private readonly faker: Faker) {
6868
// Bind `this` so namespaced is working correctly
69-
for (const name of Object.getOwnPropertyNames(AirlineModule.prototype)) {
69+
for (const name of Object.getOwnPropertyNames(
70+
AirlineModule.prototype
71+
) as Array<keyof AirlineModule | 'constructor'>) {
7072
if (name === 'constructor' || typeof this[name] !== 'function') {
7173
continue;
7274
}

src/modules/animal/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class AnimalModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(AnimalModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
AnimalModule.prototype
11+
) as Array<keyof AnimalModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/color/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ function toColorFormat(
160160
export class ColorModule {
161161
constructor(private readonly faker: Faker) {
162162
// Bind `this` so namespaced is working correctly
163-
for (const name of Object.getOwnPropertyNames(ColorModule.prototype)) {
163+
for (const name of Object.getOwnPropertyNames(
164+
ColorModule.prototype
165+
) as Array<keyof ColorModule | 'constructor'>) {
164166
if (name === 'constructor' || typeof this[name] !== 'function') {
165167
continue;
166168
}

src/modules/commerce/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
77
export class CommerceModule {
88
constructor(private readonly faker: Faker) {
99
// Bind `this` so namespaced is working correctly
10-
for (const name of Object.getOwnPropertyNames(CommerceModule.prototype)) {
10+
for (const name of Object.getOwnPropertyNames(
11+
CommerceModule.prototype
12+
) as Array<keyof CommerceModule | 'constructor'>) {
1113
if (name === 'constructor' || typeof this[name] !== 'function') {
1214
continue;
1315
}

src/modules/company/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
77
export class CompanyModule {
88
constructor(private readonly faker: Faker) {
99
// Bind `this` so namespaced is working correctly
10-
for (const name of Object.getOwnPropertyNames(CompanyModule.prototype)) {
10+
for (const name of Object.getOwnPropertyNames(
11+
CompanyModule.prototype
12+
) as Array<keyof CompanyModule | 'constructor'>) {
1113
if (name === 'constructor' || typeof this[name] !== 'function') {
1214
continue;
1315
}

src/modules/database/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class DatabaseModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(DatabaseModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
DatabaseModule.prototype
11+
) as Array<keyof DatabaseModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/datatype/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
77
export class DatatypeModule {
88
constructor(private readonly faker: Faker) {
99
// Bind `this` so namespaced is working correctly
10-
for (const name of Object.getOwnPropertyNames(DatatypeModule.prototype)) {
10+
for (const name of Object.getOwnPropertyNames(
11+
DatatypeModule.prototype
12+
) as Array<keyof DatatypeModule | 'constructor'>) {
1113
if (name === 'constructor' || typeof this[name] !== 'function') {
1214
continue;
1315
}

src/modules/date/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ function toDate(
2828
export class DateModule {
2929
constructor(private readonly faker: Faker) {
3030
// Bind `this` so namespaced is working correctly
31-
for (const name of Object.getOwnPropertyNames(DateModule.prototype)) {
31+
for (const name of Object.getOwnPropertyNames(
32+
DateModule.prototype
33+
) as Array<keyof DateModule | 'constructor'>) {
3234
if (name === 'constructor' || typeof this[name] !== 'function') {
3335
continue;
3436
}

src/modules/finance/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import iban from './iban';
88
export class FinanceModule {
99
constructor(private readonly faker: Faker) {
1010
// Bind `this` so namespaced is working correctly
11-
for (const name of Object.getOwnPropertyNames(FinanceModule.prototype)) {
11+
for (const name of Object.getOwnPropertyNames(
12+
FinanceModule.prototype
13+
) as Array<keyof FinanceModule | 'constructor'>) {
1214
if (name === 'constructor' || typeof this[name] !== 'function') {
1315
continue;
1416
}

src/modules/git/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const GIT_TIMEZONE_FORMAT = new Intl.NumberFormat('en', {
2424
export class GitModule {
2525
constructor(private readonly faker: Faker) {
2626
// Bind `this` so namespaced is working correctly
27-
for (const name of Object.getOwnPropertyNames(GitModule.prototype)) {
27+
for (const name of Object.getOwnPropertyNames(GitModule.prototype) as Array<
28+
keyof GitModule | 'constructor'
29+
>) {
2830
if (name === 'constructor' || typeof this[name] !== 'function') {
2931
continue;
3032
}

src/modules/hacker/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class HackerModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(HackerModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
HackerModule.prototype
11+
) as Array<keyof HackerModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/helpers/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import * as uniqueExec from './unique';
1010
export class HelpersModule {
1111
constructor(private readonly faker: Faker) {
1212
// Bind `this` so namespaced is working correctly
13-
for (const name of Object.getOwnPropertyNames(HelpersModule.prototype)) {
13+
for (const name of Object.getOwnPropertyNames(
14+
HelpersModule.prototype
15+
) as Array<keyof HelpersModule | 'constructor'>) {
1416
if (name === 'constructor' || typeof this[name] !== 'function') {
1517
continue;
1618
}
@@ -804,8 +806,10 @@ export class HelpersModule {
804806

805807
// Search for the requested method or definition
806808
for (const part of parts) {
807-
currentModuleOrMethod = currentModuleOrMethod?.[part];
808-
currentDefinitions = currentDefinitions?.[part];
809+
currentModuleOrMethod =
810+
currentModuleOrMethod?.[part as keyof typeof currentModuleOrMethod];
811+
currentDefinitions =
812+
currentDefinitions?.[part as keyof typeof currentDefinitions];
809813
}
810814

811815
// Make method executable
@@ -903,7 +907,13 @@ export class HelpersModule {
903907
*
904908
* @since 7.5.0
905909
*/
906-
unique<Method extends (...parameters) => RecordKey>(
910+
unique<
911+
Method extends (
912+
// TODO christopher 2023-02-14: This `any` type can be fixed by anyone if they want to.
913+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
914+
...parameters: any[]
915+
) => RecordKey
916+
>(
907917
method: Method,
908918
args?: Parameters<Method>,
909919
options: {

src/modules/helpers/unique.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ Try adjusting maxTime or maxRetries parameters for faker.helpers.unique().`
8181
* @param options.compare The function used to determine whether a value was already returned. Defaults to check the existence of the key.
8282
* @param options.store The store of unique entries. Defaults to `GLOBAL_UNIQUE_STORE`.
8383
*/
84-
export function exec<Method extends (...parameters) => RecordKey>(
84+
export function exec<
85+
Method extends (
86+
// TODO christopher 2023-02-14: This `any` type can be fixed by anyone if they want to.
87+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
88+
...parameters: any[]
89+
) => RecordKey
90+
>(
8591
method: Method,
8692
args: Parameters<Method>,
8793
options: {

src/modules/image/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ export class ImageModule {
2626

2727
constructor(private readonly faker: Faker) {
2828
// Bind `this` so namespaced is working correctly
29-
for (const name of Object.getOwnPropertyNames(ImageModule.prototype)) {
29+
for (const name of Object.getOwnPropertyNames(
30+
ImageModule.prototype
31+
) as Array<keyof ImageModule | 'constructor'>) {
3032
if (name === 'constructor' || typeof this[name] !== 'function') {
3133
continue;
3234
}
3335

34-
this[name] = this[name].bind(this);
36+
this[name] =
37+
// @ts-expect-error: remove this expect-error when we remove the deprecated sub-modules
38+
this[name].bind(this);
3539
}
3640

3741
this.unsplash = new Unsplash(this.faker);

src/modules/image/providers/placeholder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { deprecated } from '../../../internal/deprecated';
99
export class Placeholder {
1010
constructor(private readonly faker: Faker) {
1111
// Bind `this` so namespaced is working correctly
12-
for (const name of Object.getOwnPropertyNames(Placeholder.prototype)) {
12+
for (const name of Object.getOwnPropertyNames(
13+
Placeholder.prototype
14+
) as Array<keyof Placeholder | 'constructor'>) {
1315
if (name === 'constructor' || typeof this[name] !== 'function') {
1416
continue;
1517
}

src/modules/internet/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export type HTTPProtocolType = 'http' | 'https';
2929
export class InternetModule {
3030
constructor(private readonly faker: Faker) {
3131
// Bind `this` so namespaced is working correctly
32-
for (const name of Object.getOwnPropertyNames(InternetModule.prototype)) {
32+
for (const name of Object.getOwnPropertyNames(
33+
InternetModule.prototype
34+
) as Array<keyof InternetModule | 'constructor'>) {
3335
if (name === 'constructor' || typeof this[name] !== 'function') {
3436
continue;
3537
}

src/modules/location/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { deprecated } from '../../internal/deprecated';
77
export class LocationModule {
88
constructor(private readonly faker: Faker) {
99
// Bind `this` so namespaced is working correctly
10-
for (const name of Object.getOwnPropertyNames(LocationModule.prototype)) {
10+
for (const name of Object.getOwnPropertyNames(
11+
LocationModule.prototype
12+
) as Array<keyof LocationModule | 'constructor'>) {
1113
if (name === 'constructor' || typeof this[name] !== 'function') {
1214
continue;
1315
}

src/modules/lorem/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { filterWordListByLength } from '../word/filterWordListByLength';
77
export class LoremModule {
88
constructor(private readonly faker: Faker) {
99
// Bind `this` so namespaced is working correctly
10-
for (const name of Object.getOwnPropertyNames(LoremModule.prototype)) {
10+
for (const name of Object.getOwnPropertyNames(
11+
LoremModule.prototype
12+
) as Array<keyof LoremModule | 'constructor'>) {
1113
if (name === 'constructor' || typeof this[name] !== 'function') {
1214
continue;
1315
}

src/modules/music/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class MusicModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(MusicModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
MusicModule.prototype
11+
) as Array<keyof MusicModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/number/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import type { Mersenne } from '../../internal/mersenne/mersenne';
88
export class NumberModule {
99
constructor(private readonly faker: Faker) {
1010
// Bind `this` so namespaced is working correctly
11-
for (const name of Object.getOwnPropertyNames(NumberModule.prototype)) {
11+
for (const name of Object.getOwnPropertyNames(
12+
NumberModule.prototype
13+
) as Array<keyof NumberModule | 'constructor'>) {
1214
if (name === 'constructor' || typeof this[name] !== 'function') {
1315
continue;
1416
}

src/modules/person/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ function selectDefinition(
6161
export class PersonModule {
6262
constructor(private readonly faker: Faker) {
6363
// Bind `this` so namespaced is working correctly
64-
for (const name of Object.getOwnPropertyNames(PersonModule.prototype)) {
64+
for (const name of Object.getOwnPropertyNames(
65+
PersonModule.prototype
66+
) as Array<keyof PersonModule | 'constructor'>) {
6567
if (name === 'constructor' || typeof this[name] !== 'function') {
6668
continue;
6769
}

src/modules/phone/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class PhoneModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(PhoneModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
PhoneModule.prototype
11+
) as Array<keyof PhoneModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/random/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import type {
1414
export class RandomModule {
1515
constructor(private readonly faker: Faker) {
1616
// Bind `this` so namespaced is working correctly
17-
for (const name of Object.getOwnPropertyNames(RandomModule.prototype)) {
17+
for (const name of Object.getOwnPropertyNames(
18+
RandomModule.prototype
19+
) as Array<keyof RandomModule | 'constructor'>) {
1820
if (name === 'constructor' || typeof this[name] !== 'function') {
1921
continue;
2022
}

src/modules/science/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export interface Unit {
3535
export class ScienceModule {
3636
constructor(private readonly faker: Faker) {
3737
// Bind `this` so namespaced is working correctly
38-
for (const name of Object.getOwnPropertyNames(ScienceModule.prototype)) {
38+
for (const name of Object.getOwnPropertyNames(
39+
ScienceModule.prototype
40+
) as Array<keyof ScienceModule | 'constructor'>) {
3941
if (name === 'constructor' || typeof this[name] !== 'function') {
4042
continue;
4143
}

src/modules/string/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ const SAMPLE_MAX_LENGTH = 2 ** 20;
9191
export class StringModule {
9292
constructor(private readonly faker: Faker) {
9393
// Bind `this` so namespaced is working correctly
94-
for (const name of Object.getOwnPropertyNames(StringModule.prototype)) {
94+
for (const name of Object.getOwnPropertyNames(
95+
StringModule.prototype
96+
) as Array<keyof StringModule | 'constructor'>) {
9597
if (name === 'constructor' || typeof this[name] !== 'function') {
9698
continue;
9799
}

src/modules/system/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const CRON_DAY_OF_WEEK = [
3838
export class SystemModule {
3939
constructor(private readonly faker: Faker) {
4040
// Bind `this` so namespaced is working correctly
41-
for (const name of Object.getOwnPropertyNames(SystemModule.prototype)) {
41+
for (const name of Object.getOwnPropertyNames(
42+
SystemModule.prototype
43+
) as Array<keyof SystemModule | 'constructor'>) {
4244
if (name === 'constructor' || typeof this[name] !== 'function') {
4345
continue;
4446
}

src/modules/vehicle/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { Faker } from '../..';
66
export class VehicleModule {
77
constructor(private readonly faker: Faker) {
88
// Bind `this` so namespaced is working correctly
9-
for (const name of Object.getOwnPropertyNames(VehicleModule.prototype)) {
9+
for (const name of Object.getOwnPropertyNames(
10+
VehicleModule.prototype
11+
) as Array<keyof VehicleModule | 'constructor'>) {
1012
if (name === 'constructor' || typeof this[name] !== 'function') {
1113
continue;
1214
}

src/modules/word/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { filterWordListByLength } from './filterWordListByLength';
88
export class WordModule {
99
constructor(private readonly faker: Faker) {
1010
// Bind `this` so namespaced is working correctly
11-
for (const name of Object.getOwnPropertyNames(WordModule.prototype)) {
11+
for (const name of Object.getOwnPropertyNames(
12+
WordModule.prototype
13+
) as Array<keyof WordModule | 'constructor'>) {
1214
if (name === 'constructor' || typeof this[name] !== 'function') {
1315
continue;
1416
}

src/utils/types.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ export type LiteralUnion<T extends U, U = string> =
88
| (U & { zz_IGNORE_ME?: never });
99

1010
/**
11-
* Basically a function that returns a value.
11+
* A function that returns a value.
1212
*
13-
* For some strange reason this is not the same as `Function`.
13+
* `Function` cannot be used instead because it doesn't accept class declarations.
14+
* These would fail when invoked since they are invoked without the `new` keyword.
1415
*/
15-
export type Callable = (...args) => unknown;
16+
export type Callable = (
17+
// TODO christopher 2023-02-14: This `any` type can be fixed by anyone if they want to.
18+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19+
...args: any[]
20+
) => unknown;
1621

1722
/**
1823
* Type that represents a single method/function name of the given type.

test/support/seededRuns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class TestGenerator<
201201
vi_it(method, () =>
202202
this.callAndVerify(
203203
method,
204-
[] as Parameters<Module[MethodName]>,
204+
[] as unknown as Parameters<Module[MethodName]>,
205205
repetitions
206206
)
207207
);

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"allowJs": true,
1010
"alwaysStrict": true,
1111
"strictFunctionTypes": true,
12+
"noImplicitAny": true,
1213
"useUnknownInCatchVariables": true,
1314
"stripInternal": true,
1415
"baseUrl": "."

0 commit comments

Comments
 (0)