Avoiding "ESLint: Unsafe assignment of an any
value" in GetStaticProps
#445
Replies: 1 comment 1 reply
-
I have the same issue in my import { getRequestConfig } from 'next-intl/server';
export default getRequestConfig(async ({ locale }) => ({
messages: (await import(`../messages/${locale}.json`)).default,
})); 4:3 error Unsafe assignment of an Also tried to update the file to match the current documentation exactly, but got even more errors: import localeInfo from '@/localeInfo';
import { getRequestConfig } from 'next-intl/server';
import { notFound } from 'next/navigation';
const { locales } = localeInfo;
export default getRequestConfig(async ({ locale }) => {
// Validate that the incoming `locale` parameter is valid
if (!locales.includes(locale as any)) notFound();
return {
messages: (await import(`../messages/${locale}.json`)).default,
};
}); 9:25 error Unsafe argument of type |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I followed the documentation and everything is working correctly. However I have an eslint error regarding an unsafe assignment of any value. I'm guessing I'm missing a cast, but I don't really know what to cast the await import(`../../public/locales/${locale}.json`) call to. Here is the code:
This is the eslint error message:
What would be the type?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions