What's causing this Next.js type error on build?

29 views Asked by At

With Next.js 14.1.0 I got the following build error (similar to this SO post):

Type error: Type 'OmitWithTag<typeof
import("{omitted}/src/app/{omitted}/page"), "default" | "metadata" |
"config" | "generateStaticParams" | "revalidate" | "dynamic" | ... 7
more ... | "generateViewport", "">' does not satisfy the constraint '{
[x: string]: never; }'.   **Property 'SingleDatePicker' is
incompatible with index signature**.
    **Type** '({ name, value, label, minDate, maxDate, className, state, disabled, onChange }: { name: keyof InsertBidFormData; value?:
DateType | undefined; label: string; minDate?: Date | undefined;
maxDate?: Date | undefined; className?: { input?: string | undefined;
} | undefined; state?: BidFormState | undefined; disabled?: ...' **is
not assignable to type 'never'**.

This was the definition of the page in page.tsx

'use client'
//... imports
export default function Page() {
  //hooks and props
  return (
    <form>
      <SingleDatePicker name={'date'} ...props />
    </form>
  )
}

export const SingleDatePicker = (props: Props) => {
  //whatever
}
1

There are 1 answers

0
strongmmc On

It turned out that the extra 'export' to the SingleDatePicker component definition was the issue. Simply removing it:

/*export*/ const SingleDatePicker = (props: Props) => { /*...*/ }

from inside the page solved my particular case.