Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
_app.tsx to have getInitialProps and other custom props too, need proper Typscript type

My _app.tsx files what to be something on these lines

interface CmsAppProps extends AppProps {
  pageData: boolean
}

const CmsApp: NextPage<CmsAppProps> = ({ Component, pageProps, pageData }) => {
  // ...some component details
}

CmsApp.getInitialProps = async (context: NextPageContext) => {
   // some data process here
   return {
     pageData: true
   }
}

Problem here is, typescript is throwing error as: Type '(_ctx: NextPageContext) => Promise<{ pageData: true; }>' is not assignable to type '(context: NextPageContext) => CmsAppProps | Promise<CmsAppProps>'

Looks like it expense me to return data same as what is argument of component props. I cannot return Component and pageProps from getInitialProps.

If I replace type NextPage with React.FC then it obviously doesn't contain getInitialProps props. Plus doesn't has relation like what is being sent from getInitialProps also will be passed on to the component.

Is there a correct way to put everything right in typescript?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda