Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type declaration for appWithI18Next needs generic #147

Open
llamerr opened this issue Oct 1, 2022 · 0 comments
Open

Type declaration for appWithI18Next needs generic #147

llamerr opened this issue Oct 1, 2022 · 0 comments

Comments

@llamerr
Copy link

llamerr commented Oct 1, 2022

I'm using ni18n with next-auth and after I added session to my props

interface MyAppProps extends AppProps<{ session: Session }> {
  emotionCache?: EmotionCache;
}

const MyApp: React.FunctionComponent<MyAppProps> = (props) => {
  const { Component, emotionCache = clientSideEmotionCache, pageProps: { session, ...pageProps } } = props;

I started getting this type error in appWithI18Next

export default appWithI18Next/*<{ session: Session }>*/(MyApp, ni18nConfig);

TS2345: Argument of type 'FunctionComponent' is not assignable to parameter of type 'ElementType<AppInitialProps<{}> & { Component: NextComponentType<NextPageContext, any, any>; router: Router; __N_SSG?: boolean | undefined; __N_SSP?: boolean | undefined; __N_RSC?: boolean | undefined; } & { ...; }>'.   Type 'FunctionComponent' is not assignable to type 'FunctionComponent<AppInitialProps<{}> & { Component: NextComponentType<NextPageContext, any, any>; router: Router; __N_SSG?: boolean | undefined; __N_SSP?: boolean | undefined; __N_RSC?: boolean | undefined; } & { ...; }>'.     Types of parameters 'props' and 'props' are incompatible.       Type 'AppInitialProps<{}> & { Component: NextComponentType<NextPageContext, any, any>; router: Router; __N_SSG?: boolean | undefined; __N_SSP?: boolean | undefined; __N_RSC?: boolean | undefined; } & { ...; }' is not assignable to type 'MyAppProps'.

When I extended it with generic like this

declare const appWithI18Next: <T>(WrappedComponent: ElementType<AppProps<T> & {
  children?: ReactNode;
}>, options: Ni18nOptions) => ElementType;

error disappeared

I'm not sure if it's working, still finishing adding next-auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant