When ever I try to build the nextjs webapp it shows the following error. @bappyasif
Error:
Type error: Type ‘OmitWithTag<HomeProps, keyof PageProps, “default”>’ does not satisfy the constraint ‘{ [x: string]: never; }’.
Property ‘session’ is incompatible with index signature.
Type ‘Session’ is not assignable to type ‘never’.
// Check the prop type of the entry function
checkFields<Diff<PageProps, FirstArg<TEntry[‘default’]>, ‘default’>>()
^
// Check the arguments and return type of the generateMetadata function
if (‘generateMetadata’ in entry) {
'use client'
import Modal from '@/components/Modal'
import Header from '@/components/layout/Header'
import { FC } from 'react'
import { SessionProvider } from 'next-auth/react'
import { Session } from 'next-auth'
import Form from '@/components/Form'
import PostFeed from '@/components/Posts/PostFeed'
interface HomeProps {
session: Session
}
const Home: FC<HomeProps> = ({ session }) => {
return (
<>
<SessionProvider session={session}>
<Header label='Home' />
<Form placeholder='Whats Happening?' />
<PostFeed />
</SessionProvider>
</>
)
}
export default Home
I was getting the same error.
First, I managed to fix the provider problem by following the first answer here:
After that, I had a type problem with the type of the provider’s return. It seems to be a well known problem using typescript in react.
Not exaclty the same problem as here, but almost the same.
I got it working by not returning a React.ReactNode from my provider and set it to any.
Certainly not the best solution to the problem, but at least it made it work.