🫱[ERROR] export default async function Page({ params }: { params: { slug: string[] } }) { ... }
https://github.com/orgs/community/discussions/142577
Last updated
Was this helpful?
https://github.com/orgs/community/discussions/142577
Last updated
Was this helpful?
Answered by night-fury-3Universe0809 asked this question in CodespacesPageProps Type Errors in Next.js#142577Universe0809on Oct 25 · 7 comments · 18 replies Answered by night-fury-3 Return to top
Bug
Hello everyone,
I am working on a project using Next.js 15 and have defined my page as follows:
export default async function Page({ params }: { params: { slug: string[] } }) { ... }
However, during the build process, I encounter the following TypeScript error:
Type error: Type '{ params: { slug: string[]; }; }' does not satisfy the constraint 'PageProps'. Types of property 'params' are incompatible. Type '{ slug: string[]; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
Could you advise on how to correctly resolve these type issues or effectively suppress this error? I've attempted to use the comment // @ts-expect-error: params type does not match expected PageProps, but the error persists.
Thank you for your assistance!
78
Answered by night-fury-3on Oct 25
Hi @Universe0809, It appears that there are breaking changes in Next.js version 15 related to properties such as params. The official documentation highlights this issue (see: Next.js v15 Upgrade Guide).
To address these changes, you have a couple of options:
Downgrade: Consider reverting to an earlier version of Next.js where these breaking changes do not apply.
Update your Code: You can handle the params by awaiting them in your function as follows: `type Params = Promise<{ slug: string[] }>;
export default async function Page({ params }: { params: Params }) { const { slug } = await params; }`
This approach ensures that your application remains compatible with the latest version of Ne…
💬 Your Product Feedback Has Been Submitted 🎉
Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users.
Here's what you can expect moving forward ⏩
Your input will be carefully reviewed and cataloged by members of our product teams.
Due to the high volume of submissions, we may not always be able to provide individual responses.
Rest assured, your feedback will help chart our course for product improvements.
Other users may engage with your post, sharing their own perspectives or experiences.
GitHub staff may reach out for further clarification or insight.
We may 'Answer' your discussion if there is a current solution, workaround, or roadmap/changelog post related to the feedback.
Where to look to see what's shipping 👀
Read the Changelog for real-time updates on the latest GitHub features, enhancements, and calls for feedback.
Explore our Product Roadmap, which details upcoming major releases and initiatives.
What you can do in the meantime 💻
Upvote and comment on other user feedback Discussions that resonate with you.
Add more information at any point! Useful details include: use cases, relevant labels, desired outcomes, and any accompanying screenshots.
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities.
Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐
12
0 repliesWrite a reply
error happens because TypeScript thinks params should be a Promise, not a plain object. Use Type Assertion: Tell TypeScript to ignore the type issue by adding as any:
export default async function Page({ params }: { params: { slug: string[] } } as any) { // ur function code here }
12
0 repliesWrite a reply
Hi @Universe0809, It appears that there are breaking changes in Next.js version 15 related to properties such as params. The official documentation highlights this issue (see: Next.js v15 Upgrade Guide).
To address these changes, you have a couple of options:
Downgrade: Consider reverting to an earlier version of Next.js where these breaking changes do not apply.
Update your Code: You can handle the params by awaiting them in your function as follows: `type Params = Promise<{ slug: string[] }>;
export default async function Page({ params }: { params: Params }) { const { slug } = await params; }`
This approach ensures that your application remains compatible with the latest version of Next.js.
Thank you for taking my suggestion into account. Please feel free to contact me if you have any questions.
Marked as answer1718
Rolling back works. In my case "next": "^14.2.17",
我不觉得类型脚本有什么
Same feeling but why so many use ts, please let me just drop the benefits of ts
Thanks. It worked!
@landed1 hello, how do i roll back. I have tried deleting the nodemodules and then installing a specific next js version but couldn't succeed. Can you please help me with it? Thank you
I edited the package.json and then I think it's npm update to rollback.
Write a replyAnswer selected by Universe0809
34
thank you very very much bro
Write a reply
If you’ve encountered the same issue I did, it was due to having a monorepo with multiple React dependencies. Specifically, one of my packages was still using React 18, which caused a type mismatch.
12
0 repliesWrite a replyedited
I had the same issue but it was more than one file that needed to be changed. So if anyone encounters the same issue just run this command in the terminal. It will fix all the files for you. npx @next/codemod@canary next-async-request-api .
12
hans't solve the issue for me!
Write a reply
Is next turning into a too much opinionated
framework?