I'm working on a Next.js 15 application and encountered the following TypeScript error:
Answered
yakkshit posted this in #help-forum
yakkshitOP
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.
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 }>;
}
8 Replies
Asian black bear
You should wrap it in Promise:
interface DocPageProps {
params: Promise<{
slug?: string[];
}>;
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}
Answer
Asian black bear
The return type of that function must be
Or just remove the return type!
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!
yakkshitOP
i didn't get it
i mean i'm still getting the same error
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
https://nextjs.org/docs/app/building-your-application/upgrading/version-15#params--searchparams
yakkshitOP
here is the complete code
"https://github.com/yakkshit/ui/blob/main/app/(docs)/docs/%5B%5B...slug%5D%5D/page.tsx'
"
"https://github.com/yakkshit/ui/blob/main/app/(docs)/docs/%5B%5B...slug%5D%5D/page.tsx'
"