Next-i18next: Type error: Type 'null' is not assignable to type 'UserConfig'.

Created on 26 Feb 2021  路  3Comments  路  Source: isaachinman/next-i18next

Describe the bug

yarn build is throwing Type error: Type 'null' is not assignable to type 'UserConfig'.

Occurs in next-i18next version

8.0.2

Steps to reproduce

Contents of next-i18next.config.js:

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en'],
  },
};

Contents of next.config.js:

const { i18n } = require('./next-i18next.config');

module.exports = {
  i18n,
};

Contents of pages/_app.tsx:

import { wrapper } from '@core/redux/store';
import type { AppProps } from 'next/app';
import React from 'react';
import { appWithTranslation } from 'next-i18next';

const App = ({ Component, pageProps }: AppProps) => {
  return <Component {...pageProps} />;
};

export default appWithTranslation(wrapper.withRedux(App));

Contens of pages/index.tsx:

import Locale from '@custom-types/locale';
import { NextPage } from 'next';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import React from 'react';

type IProps = {
  hello: string;
};

const IndexPage: NextPage<IProps> = ({ hello }) => {
  const { t } = useTranslation('common');

  return (
    <div>
      <h1>{t('h1')}</h1>
      {hello}
    </div>
  );
};

export async function getServerSideProps({ locale }: Locale) {
  return {
    props: {
      hello: 'world',
      ...(await serverSideTranslations(locale, ['common', 'footer'])),
    },
  };
}

export default IndexPage;

Expected behaviour

yarn build should build the Next.js project without throwing any errors.

Screenshots

Screenshot 2021-02-26 at 4 21 59 PM

OS (please complete the following information)

  • Device: MacBook Air 2019, macOS BigSur
  • Browser: Chrome 88.0.4324.192

Most helpful comment

I'm going to close this in favour of #995. I have created a repo there and would love if someone can assist in helping me repro these issues. Thanks!

All 3 comments

This issue probably has a similar root cause to #995

This issue probably has a similar root cause to #995

Yeah, probably. I don't have the problem if I use 8.0.1.

I'm going to close this in favour of #995. I have created a repo there and would love if someone can assist in helping me repro these issues. Thanks!

Was this page helpful?
0 / 5 - 0 ratings