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:
+3
-1
@@ -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') {
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -22,5 +22,5 @@ export const adrTranslationRef = createTranslationRef({
|
||||
content_header_title: 'Architecture Decision Records',
|
||||
failed_to_fetch: 'Failed to fetch ADRs',
|
||||
no_adrs: 'No ADRs found',
|
||||
} as const,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -30,5 +30,5 @@ export const userSettingsTranslationRef = createTranslationRef({
|
||||
select_theme: 'Select {{theme}}',
|
||||
select_theme_auto: 'Select Auto Theme',
|
||||
select_lng: 'Select language {{language}}',
|
||||
} as const,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user