I am trying to locate the user's browser language from a list of supported languages. Here is the code snippet I am using:
const userLanguage = browserLanguages.find(language => !!supported[language]);
But unfortunately, I'm encountering this error message:
Element implicitly has an 'any' type because type 'LanguageName' has no index signature.
The LanguageName
type is specifically defined for my supported
object:
type LanguageName = {
[language in SupportedLanguages]: string;
};
And just so you know, supportedLanguages
is a typescript containing all the languages that our app supports:
type SupportedLanguages = 'en' | 'es';