What TypeScript type should NextJS _app.tsx Component and pageProps be?


Here’s the default _app.tsx from NextJS:

function MyApp({ Component, pageProps }) {
  return (
    <Component {...pageProps} />

The problem is, as soon as you switch to TypeScript, you get a warning under ES6Lint that these types are intrinsicly set to type ‘any’. That being said, I can’t figure out what type to set these two to that wont cause more errors later of mismatched types. What TypeScript types should I cast these two as?


You could import the types from nextjs.

import { AppProps } from 'next/app';

function MyApp({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />

Answered By – kind user

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.