How can i fix that type error? TS2339: Property 'DisplayNames' does not exist on type 'typeof Intl'.
my function:
export const getLanguageName = (locale: string | null) => {
const localeName = new Intl.DisplayNames([locale], { type: 'language' });
return localeName.of(locale);
};
If you arrived here looking for an Angular solution, I think it's safe to just use target: "es2020"
and update your library declarations in your tsconfig.base.ts (at the root level)
{
"compilerOptions": {
...
"target": "es2020",
"lib": ["dom", "es2020"]
}
}
That should give you access to the new Intl API types definitions removing the errors from your editor and also any possible compilation errors. A few years ago we could only use es2015 due to some issues with async/await and zone.js but this was addressed in 2021.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With