Description
Description
- I added
next-intl
to a boilerplate TS next project by following the documentation and the official example. - I added typescript-eslint for ESLint TypeScript support. by following the instructions here.
- Finally, I enabled typed linting.
Upon running npx eslint .
, I get the following errors for my i18n.ts
file:
9:25 error Unsafe argument of type any
assigned to a parameter of type string
@typescript-eslint/no-unsafe-argument
9:35 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
12:5 error Unsafe assignment of an any
value @typescript-eslint/no-unsafe-assignment
12:60 error Unsafe member access .default on an any
value @typescript-eslint/no-unsafe-member-access
i18n.ts
:
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,
};
});
I also found a discussion where another developer has reported the same issue: #445
Btw, in case I disable type-checked linting for the specific file, there is still an error, which is for the explicit any
:
9:35 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
Mandatory reproduction URL
https://github.com/amannn/next-intl/tree/main/examples/example-app-router
Reproduction description
- Follow what I wrote in the "Description" section. Make sure that you have enabled typescript-eslint's linting with type information feature.
- Run
npx eslint .
Expected behaviour
There should be no errors and the documentation should not contain code which uses implicit or explicit any
types.