Fix TS errors

This commit is contained in:
ErickSkrauch 2020-07-21 16:23:32 +03:00
parent 9faf7cf404
commit 75a7de2af2
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
2 changed files with 5 additions and 6 deletions

View File

@ -17,10 +17,9 @@ export function getCountriesList(): string[] {
return SUPPORTED_LANGUAGES.map((locale) => localeToCountryCode[locale] || locale);
}
const flagIconLoadingChain: ReadonlyArray<(locale: string) => string | { default: string }> = [
const flagIconLoadingChain: ReadonlyArray<(locale: string) => { default: string }> = [
(locale) => require(`./flags/${locale}.svg`),
(locale) => require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] || locale}.svg`),
() => require('./flags/unknown.svg'),
];
/**
@ -34,13 +33,13 @@ const flagIconLoadingChain: ReadonlyArray<(locale: string) => string | { default
export function getLocaleIconUrl(locale: string): string {
for (const flagIconLoadingChainElement of flagIconLoadingChain) {
try {
const mod = flagIconLoadingChainElement(locale);
return mod.default || mod;
return flagIconLoadingChainElement(locale).default;
} catch (err) {
if (!err.message.startsWith('Cannot find module')) {
throw err;
}
}
}
return require('./flags/unknown.svg').default;
}

View File

@ -30,7 +30,7 @@ storiesOf('Components/Profile', module).add('Profile', () => (
avatar: '',
token: '',
}}
interfaceLocale={'en'}
activeLocale={'en'}
/>
</ProfileLayout>
));