Layout params union types casted to string..
Unanswered
Couch's Kingbird posted this in #help-forum
Couch's KingbirdOP
Build is failing because next js cast union type to string.
Types of property 'params' are incompatible.
Type 'Promise<{ locale: string; }>' is not assignable to type 'Promise<{ locale: "fr" | "nl" | "en"; }>'.
Types of property 'params' are incompatible.
Type 'Promise<{ locale: string; }>' is not assignable to type 'Promise<{ locale: "fr" | "nl" | "en"; }>'.
export const dynamicParams = false;
export async function generateStaticParams(): Promise<{ locale: Locale }[]> {
return i18n.locales.map((locale) => ({ locale }));
}
export default async function LocaleLayout({children, params}: {
children: React.ReactNode;
params: Promise<{ locale: Locale }>;
}) {
const { locale } = await params;
const { tr, dict } = await getTranslations(locale);1 Reply
@Couch's Kingbird Build is failing because next js cast union type to string.
Types of property 'params' are incompatible.
Type 'Promise<{ locale: string; }>' is not assignable to type 'Promise<{ locale: "fr" | "nl" | "en"; }>'.
js
export const dynamicParams = false;
export async function generateStaticParams(): Promise<{ locale: Locale }[]> {
return i18n.locales.map((locale) => ({ locale }));
}
export default async function LocaleLayout({children, params}: {
children: React.ReactNode;
params: Promise<{ locale: Locale }>;
}) {
const { locale } = await params;
const { tr, dict } = await getTranslations(locale);
I wasn’t able to replicate that. For me it works like that. Can you provide a reproduction repo so we can have a look at it in detail?