core-plugin-api: remove the need to declare translation messages as const

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-09-17 11:41:48 +02:00
parent f4abd00ac2
commit a68326c95a
6 changed files with 8 additions and 6 deletions
@@ -360,7 +360,9 @@ describe('I18nextTranslationApi', () => {
await new Promise<void>(resolve => {
const subscription = translationApi.translation$(plainRef).subscribe({
next(snapshot) {
const translation = snapshot.ready ? snapshot.t('foo') : null;
const translation = snapshot.ready
? (snapshot.t('foo') as string)
: null;
translations.push(translation);
if (translation === 'foo') {
+1 -1
View File
@@ -41,7 +41,7 @@ export function createTranslationMessages<
// @alpha (undocumented)
export function createTranslationRef<
TId extends string,
TMessages extends {
const TMessages extends {
[key in string]: string;
},
TTranslations extends {
@@ -23,7 +23,7 @@ const ref = createTranslationRef({
one: 'one',
two: 'two',
three: 'three',
} as const,
},
});
describe('createTranslationMessages', () => {
@@ -108,7 +108,7 @@ class TranslationRefImpl<
/** @alpha */
export function createTranslationRef<
TId extends string,
TMessages extends { [key in string]: string },
const TMessages extends { [key in string]: string },
TTranslations extends {
[language in string]: () => Promise<{
default: { [key in keyof TMessages]: string | null };