Next.js Discord

Discord Forum

Layout params union types casted to string..

Unanswered
Couch's Kingbird posted this in #help-forum
Open in Discord
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"; }>'.


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