diff --git a/packages/next/pages/_app.tsx b/packages/next/pages/_app.tsx index 691555628145..c646d0842fea 100644 --- a/packages/next/pages/_app.tsx +++ b/packages/next/pages/_app.tsx @@ -5,10 +5,11 @@ import { AppInitialProps, AppPropsType, NextWebVitalsMetric, + AppType, } from '../shared/lib/utils' import type { Router } from '../client/router' -export { AppInitialProps } +export { AppInitialProps, AppType } export { NextWebVitalsMetric } diff --git a/packages/next/shared/lib/utils.ts b/packages/next/shared/lib/utils.ts index ec5197e0c3b9..76b9eee3a520 100644 --- a/packages/next/shared/lib/utils.ts +++ b/packages/next/shared/lib/utils.ts @@ -27,10 +27,10 @@ export type DocumentType = NextComponentType< DocumentProps > -export type AppType = NextComponentType< +export type AppType

= NextComponentType< AppContextType, - AppInitialProps, - AppPropsType + P, + AppPropsType > export type AppTreeType = ComponentType< diff --git a/test/integration/typescript/pages/_app.tsx b/test/integration/typescript/pages/_app.tsx index bc26412e55da..adc878fa93ec 100644 --- a/test/integration/typescript/pages/_app.tsx +++ b/test/integration/typescript/pages/_app.tsx @@ -1,20 +1,9 @@ -// import App from "next/app"; -import type { AppProps /*, AppContext */ } from 'next/app' +import type { AppType } from 'next/app' -function MyApp({ Component, pageProps }: AppProps) { +const MyApp: AppType<{ foo: string }> = ({ Component, pageProps }) => { return } -// Only uncomment this method if you have blocking data requirements for -// every single page in your application. This disables the ability to -// perform automatic static optimization, causing every page in your app to -// be server-side rendered. -// -// MyApp.getInitialProps = async (appContext: AppContext) => { -// // calls page's `getInitialProps` and fills `appProps.pageProps` -// const appProps = await App.getInitialProps(appContext); - -// return { ...appProps } -// } +MyApp.getInitialProps = () => ({ foo: 'bar' }) export default MyApp