I am going through the Next JS course and learning Routing and Navigation. While learning"unexpected errors" when I have to build my solution it shows below error and I am not able to find a solution for it.
next-app@0.1.0 build
next build
▲ Next.js 15.0.2
Creating an optimized production build …
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
app/products/[[…slug]]/page.tsx
Type error: Type ‘Props’ does not satisfy the constraint ‘PageProps’.
Types of property ‘params’ are incompatible.
Type ‘{ slug: string; }’ is missing the following properties from type ‘Promise’: then, catch, finally, [Symbol.toStringTag]
Type error: Type 'Props' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ id: number; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
So I was able to fix it. It looks like an update to NextJS, something to do with params and searchParams becoming Async, see here.
You can run the below command from the root of your project directory, and it will attempt to fix the files automatically: npx @next/codemod@canary next-async-request-api .
For me, it fixed all but one, and I just had to manually edit the Props interface. Your ProductPage should look like this when it’s fixed: