From 75a7de2af26061ae03cdfacb2f57f895e6fb8c86 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 21 Jul 2020 16:23:32 +0300 Subject: [PATCH] Fix TS errors --- packages/app/components/i18n/localeFlags.ts | 9 ++++----- packages/app/components/profile/Profile.story.tsx | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/app/components/i18n/localeFlags.ts b/packages/app/components/i18n/localeFlags.ts index c9d4d96..2b5f426 100644 --- a/packages/app/components/i18n/localeFlags.ts +++ b/packages/app/components/i18n/localeFlags.ts @@ -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; } diff --git a/packages/app/components/profile/Profile.story.tsx b/packages/app/components/profile/Profile.story.tsx index daea51e..637f119 100644 --- a/packages/app/components/profile/Profile.story.tsx +++ b/packages/app/components/profile/Profile.story.tsx @@ -30,7 +30,7 @@ storiesOf('Components/Profile', module).add('Profile', () => ( avatar: '', token: '', }} - interfaceLocale={'en'} + activeLocale={'en'} /> ));