Is there something like the new global PageProps and LayoutProps or should the user import ParamMap?
Unanswered
American Curl posted this in #help-forum
American CurlOP
Hi,
migrating to the 15.5 typed routes and I'd like to also use that to type generateStaticParams.
Sadly there doesn't seem to be a generic type in the global declaration.
Meaning in the end i have to do
with importing ParamsOf manually from the generated .next/types/routes
migrating to the 15.5 typed routes and I'd like to also use that to type generateStaticParams.
Sadly there doesn't seem to be a generic type in the global declaration.
Meaning in the end i have to do
export async function generateStaticParams({
params,
}: {
params: ParamsOf<"/[locale]/[country]/foo/bar">;
}) {
const country = params.country;
with importing ParamsOf manually from the generated .next/types/routes
3 Replies
chatgpt is going to give you the wrong answers for this in most cases as it still references old documentations, params needs to be awaited, However, refer to this.
also you have PageProps, LayoutProps, and RouteContext.
https://nextjs.org/docs/app/api-reference/file-conventions/page
also you have PageProps, LayoutProps, and RouteContext.
https://nextjs.org/docs/app/api-reference/file-conventions/page
@American Curl Hi,
migrating to the 15.5 typed routes and I'd like to also use that to type generateStaticParams.
Sadly there doesn't seem to be a generic type in the global declaration.
Meaning in the end i have to do
export async function generateStaticParams({
params,
}: {
params: ParamsOf<"/[locale]/[country]/foo/bar">;
}) {
const country = params.country;
with importing ParamsOf manually from the generated .next/types/routes
you can technically do
but it looks ugly yeah. not much else you can do here though other than manually declaring
type Params = Awaited<PageProps<"...">["params"]>
but it looks ugly yeah. not much else you can do here though other than manually declaring
type Params = { locale: string, country: string }
@Rubix chatgpt is going to give you the wrong answers for this in most cases as it still references old documentations, params needs to be awaited, However, refer to this.
also you have PageProps, LayoutProps, and RouteContext.
https://nextjs.org/docs/app/api-reference/file-conventions/page
American CurlOP
is this actually true? Params in generateStaticParams is the object and not a promise. Also according to the docs https://nextjs.org/docs/app/api-reference/functions/generate-static-params#generate-params-from-the-top-down