Upgrade to typescript-eslint v6 (#25904)

This commit is contained in:
Renaud Chaput
2023-07-13 11:49:16 +02:00
committed by GitHub
parent 3ed9b55cb3
commit a7253075d1
23 changed files with 133 additions and 107 deletions

View File

@ -3,15 +3,19 @@ export interface LocaleData {
messages: Record<string, string>;
}
let loadedLocale: LocaleData;
let loadedLocale: LocaleData | undefined;
export function setLocale(locale: LocaleData) {
loadedLocale = locale;
}
export function getLocale() {
if (!loadedLocale && process.env.NODE_ENV === 'development') {
throw new Error('getLocale() called before any locale has been set');
export function getLocale(): LocaleData {
if (!loadedLocale) {
if (process.env.NODE_ENV === 'development') {
throw new Error('getLocale() called before any locale has been set');
} else {
return { locale: 'unknown', messages: {} };
}
}
return loadedLocale;