next-rosetta icon indicating copy to clipboard operation
next-rosetta copied to clipboard

Property 'table' does not exist on type '{}'

Open AimanAlmureish opened this issue 1 year ago • 3 comments

I am trying to implement it on a Next js project and I get the following error in the _app.tsx


import { I18nProvider } from "next-rosetta";
import type { ReactElement, ReactNode } from "react";
import type { NextPage } from "next";
import { AppProps } from "next/app";
import Layout from "../components/layout/layout";
import "../styles/globals.css";
import "../styles/kvass.min.css";

export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
  getLayout?: (page: ReactElement) => ReactNode;
};

type AppPropsWithLayout = AppProps & {
  Component: NextPageWithLayout;
};

function MyApp({ Component, pageProps }: AppPropsWithLayout) {
  const getLayout = Component.getLayout ?? ((page) => page);

  return (
    <I18nProvider table={pageProps.table}>
      {getLayout(<Component {...pageProps} />)}
    </I18nProvider>
  );
}

export default MyApp;


The pageProps.table is showing this error Property 'table' does not exist on type '{}'

AimanAlmureish avatar Oct 25 '22 21:10 AimanAlmureish

Any ideas on how to fix it?

AimanAlmureish avatar Oct 25 '22 21:10 AimanAlmureish

Try this:

UPDATED

import type { AppProps } from "next/app";
import { type I18nProps, I18nProvider } from "next-rosetta";

import type { MyLocale } from "../i18n";

export default function App({ Component, pageProps }: AppProps<I18nProps<MyLocale>>) {
  return (
    <I18nProvider table={pageProps.table}>
      ...
    </I18nProvider>
  );
}

lopezjurip avatar Oct 26 '22 14:10 lopezjurip

So sorry for the late response! With my code I get this now Type 'AppPropsWithLayout' is not generic.ts(2315)

This is because I am using the layout. Any fixes for this?

AimanAlmureish avatar Nov 13 '22 16:11 AimanAlmureish