Next.js Discord

Discord Forum

I'm working on a Next.js 15 application and encountered the following TypeScript error:

Answered
yakkshit posted this in #help-forum
Open in Discord
Avatar
app/(docs)/docs/[[...slug]]/page.tsx Type error: Type 'DocPageProps' does not satisfy the constraint 'PageProps'. Types of property 'params' are incompatible. Type '{ slug?: string[] | undefined; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]

for code here is repo link 'https://github.com/yakkshit/ui/blob/main/app/(docs)/docs/%5B%5B...slug%5D%5D/page.tsx'

I tried async, await but still i'm getting the same error.

can anyone help me with resolving the issues in my project.
Answered by Asian black bear
You should wrap it in Promise:
interface DocPageProps {
  params: Promise<{
    slug?: string[];
  }>;
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}
View full answer

8 Replies

Avatar
Asian black bear
You should wrap it in Promise:
interface DocPageProps {
  params: Promise<{
    slug?: string[];
  }>;
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}
Answer
Avatar
i'm getting this error can you help me
Image
Avatar
Asian black bear
The return type of that function must be Promise<{ slug?: string[]; }>. Looks like you're just using a type that's wrapped with Promise. Either create a new type without promise, or wrap it again with Awaited<...> as the return type.

Or just remove the return type!
Avatar
i didn't get it
i mean i'm still getting the same error
Image
Avatar
Asian black bear
Could you show me what your DocPageProps looks like? Reading the error, looks like you don't wrap the params in a Promise
I recommend that you check out this section of the migration guide to Next 15:
https://nextjs.org/docs/app/building-your-application/upgrading/version-15#params--searchparams