I'm using Next.js 15 with the App Router, and I have a dynamic route: app/blog/[slug]/page.tsx.
Everything works fine at runtime, but during build I get this type error from an auto-generated file:
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]
This is strange because in my actual page.tsx, params is used like this:
export default async function BlogPost({
params,
}: {
params: { slug: string };
}) {
const article = blogArticles.find((article) => article.slug === params.slug);
if (!article) {
notFound();
}
return (
<DefaultLayout>
<ArticleLayout
title={article.title}
date={article.date}
image={article.image}
duration={article.duration}
>
<ArticleBody slug={params.slug} />
</ArticleLayout>
</DefaultLayout>
);
}
export async function generateMetadata({
params,
}: {
params: { slug: string };
}): Promise<Metadata> {
...
}
So far everything is working — until the build fails due to .next/types/....