Next.js Discord

Discord Forum

Type Error in `.next/types/app/(Home)/post/page.ts:8:13`

Answered
Havana posted this in #help-forum
Open in Discord
HavanaOP
Hello, I got this weird error when building my app.

Error:
> bun run rebuild
$ next build && next start
   â–² Next.js 14.1.3
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  .Failed to compile.

.next/types/app/(Home)/post/page.ts:8:13
Type error: Type 'OmitWithTag<typeof import("C:/Personal/VSCode/Github/OmarAfet/Dqween/src/app/(Home)/post/page"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | ... 7 more ... | "generateViewport", "">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'postSchema' is incompatible with index signature.
    Type 'ZodObject<{ title: ZodString; description: ZodString; price: ZodString; region: ZodEnum<[string, ...string[]]>; districts: ZodEnum<[string, ...string[]]>; phone: ZodString; }, "strip", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'never'.

   6 |
   7 | // Check that the entry is a valid entry
>  8 | checkFields<Diff<{
     |             ^
   9 |   default: Function
  10 |   config?: {}
  11 |   generateStaticParams?: Function
error: script "rebuild" exited with code 1
Answered by joulev
make a separate file, say app/(Home)/post/post-schema.ts, declare the postSchema const there and export it from there
View full answer

5 Replies

Answer
do not export postSchema from the page.tsx file itself
the page file can only export certain things and postSchema is not one of them
HavanaOP
Let me try that
it works!