Closed addlistener closed 3 months ago
What should be the locale type here?
// pages/_app.tsx import { I18nProvider } from '../locales' import { AppProps } from 'next/app' export default function App({ Component, pageProps }: AppProps) { return ( <I18nProvider locale={pageProps.locale}> <Component {...pageProps} /> </I18nProvider> ) }
I tried using typeof en but there's type mismatch. Even though all the locales are the same.
typeof en
// locales/en.ts export default { "product slogan": "xxxx", "dash": { "leftnav": { "sites": "xxxx", "account": "xxxx" } } } as const
I don't know it's FlattenLocale or as const. Still thinking...
FlattenLocale
as const
The deducted type
My type
It's a complex type: to avoid manually writing it, you can use:
ComponentProps<typeof I18nProvider>['locale']
Thank you! It would be great this could be included in the official examples
What should be the locale type here?
I tried using
typeof en
but there's type mismatch. Even though all the locales are the same.I don't know it's
FlattenLocale
oras const
. Still thinking...The deducted type
My type