Skip to content

Commit 87f1e16

Browse files
committed
Small tweak
1 parent f7d9f60 commit 87f1e16

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/06-challenges/34-internationalization.solution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ type GetParamKeys<TTranslation extends string> = TTranslation extends ""
99
const translate = <
1010
TTranslations extends Record<string, string>,
1111
TKey extends keyof TTranslations,
12-
TComputedArgs extends string[] = GetParamKeys<TTranslations[TKey]>,
12+
TParamKeys extends string[] = GetParamKeys<TTranslations[TKey]>,
1313
>(
1414
translations: TTranslations,
1515
key: TKey,
16-
...args: TComputedArgs extends []
16+
...args: TParamKeys extends []
1717
? []
18-
: [params: Record<TComputedArgs[number], string>]
18+
: [params: Record<TParamKeys[number], string>]
1919
) => {
2020
const translation = translations[key];
2121
const params: any = args[0] || {};
@@ -26,7 +26,7 @@ const translate = <
2626
// TESTS
2727

2828
const translations = {
29-
title: "Hello, {firstName} {surname}!",
29+
title: "Hello, {name}!",
3030
subtitle: "You have {count} unread messages.",
3131
button: "Click me!",
3232
} as const;
@@ -39,7 +39,7 @@ it("Should translate a translation without parameters", () => {
3939

4040
it("Should translate a translation WITH parameters", () => {
4141
const subtitle = translate(translations, "subtitle", {
42-
count: "2",
42+
count: "123123",
4343
});
4444

4545
expect(subtitle).toEqual("You have 2 unread messages.");

0 commit comments

Comments
 (0)