Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AimanAlmureish opened this issue Oct 25, 2022 · 3 comments
Open

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

AimanAlmureish opened this issue Oct 25, 2022 · 3 comments

Comments

@AimanAlmureish
Copy link

AimanAlmureish commented Oct 25, 2022

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
Copy link
Author

Any ideas on how to fix it?

@lopezjurip
Copy link
Member

lopezjurip commented Oct 26, 2022

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>
  );
}

@AimanAlmureish
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants