From eda3262b598159925a620235f24cd0eb124dd9a2 Mon Sep 17 00:00:00 2001 From: TheOnlyTails Date: Sun, 18 Feb 2024 19:23:08 +0200 Subject: [PATCH] fixed getTranslatedData types (#50) --- schemas/src/utils.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/schemas/src/utils.ts b/schemas/src/utils.ts index 1772ca0c12..6e2ab32ac1 100644 --- a/schemas/src/utils.ts +++ b/schemas/src/utils.ts @@ -61,9 +61,10 @@ export type LocalizedSignParameters = ParametersTranslation[string]; export type FontLinks = Font["links"]; export function getTranslatedData< - L extends object, - K extends keyof L, - T extends { translations: { en: L } & Record }, ->(data: T, key: K, language: string): L[K] { - return (data.translations[language] ?? data.translations["en"])[key]; + Obj extends { translations: Record }, + Key extends keyof Obj["translations"][string], +>(data: Obj, key: Key, language: string): Obj["translations"][string][Key] { + return ((data.translations[language] ?? data.translations["en"]!) as Obj["translations"][string])[ + key + ]; }