aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorShinigami <[email protected]>2023-05-04 16:42:29 +0200
committerGitHub <[email protected]>2023-05-04 16:42:29 +0200
commit2e9ed960e3a11e4dcb78a434563fc04890c00c3d (patch)
tree566aa44b9bb085b8a42c6f211b7ea93af4d8408f /scripts
parent0740aa0da3b2ac1da4fd8a134d650162457552b4 (diff)
downloadfaker-2e9ed960e3a11e4dcb78a434563fc04890c00c3d.tar.xz
faker-2e9ed960e3a11e4dcb78a434563fc04890c00c3d.zip
chore: rename generics (#2046)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/apidoc/utils.ts8
-rw-r--r--scripts/generateLocales.ts7
2 files changed, 8 insertions, 7 deletions
diff --git a/scripts/apidoc/utils.ts b/scripts/apidoc/utils.ts
index 8a002f49..4f8d3440 100644
--- a/scripts/apidoc/utils.ts
+++ b/scripts/apidoc/utils.ts
@@ -47,10 +47,10 @@ export function adjustUrls(description: string): string {
return description.replace(/https:\/\/(next.)?fakerjs.dev\//g, '/');
}
-export function mapByName<T extends { name: string }, V>(
- input: T[],
- valueExtractor: (item: T) => V
-): Record<string, V> {
+export function mapByName<TInput extends { name: string }, TValue>(
+ input: TInput[],
+ valueExtractor: (item: TInput) => TValue
+): Record<string, TValue> {
return input.reduce(
(acc, item) => ({ ...acc, [item.name]: valueExtractor(item) }),
{}
diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts
index 591b6810..b1c4db0e 100644
--- a/scripts/generateLocales.ts
+++ b/scripts/generateLocales.ts
@@ -40,9 +40,10 @@ const pathDocsGuideLocalization = resolve(
);
// Workaround for nameOf<T>
-type PascalCase<S extends string> = S extends `${infer P1}_${infer P2}`
- ? `${Capitalize<P1>}${PascalCase<P2>}`
- : Capitalize<S>;
+type PascalCase<TName extends string> =
+ TName extends `${infer Prefix}_${infer Remainder}`
+ ? `${Capitalize<Prefix>}${PascalCase<Remainder>}`
+ : Capitalize<TName>;
type DefinitionType = {
[key in keyof LocaleDefinition]-?: PascalCase<`${key}Definition`>;