From e3d09f5c7cc173d25dd33e5dddee2297f26b9d64 Mon Sep 17 00:00:00 2001 From: Dave Welsh <33357025+davewelsh@users.noreply.github.com> Date: Tue, 25 Jan 2022 13:26:21 -0500 Subject: [PATCH 1/2] Update layouts.md By allowing `NextPageWithLayout` to accept an optional generic type, we can continue to specify our props explicitly on pages that use this type. This gives us type safety in `getInitialProps`, for example. --- docs/basic-features/layouts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/basic-features/layouts.md b/docs/basic-features/layouts.md index ea9bfd6f1424e..14ebfdc427939 100644 --- a/docs/basic-features/layouts.md +++ b/docs/basic-features/layouts.md @@ -125,12 +125,12 @@ import type { ReactElement, ReactNode } from 'react' import type { NextPage } from 'next' import type { AppProps } from 'next/app' -type NextPageWithLayout = NextPage & { +type NextPageWithLayout = NextPage & { getLayout?: (page: ReactElement) => ReactNode } type AppPropsWithLayout = AppProps & { - Component: NextPageWithLayout + Component: NextPageWithLayout } export default function MyApp({ Component, pageProps }: AppPropsWithLayout) { From 16d8255df6c87f7654c3a1b2dde40cbee27da314 Mon Sep 17 00:00:00 2001 From: Dave Welsh Date: Tue, 25 Jan 2022 14:21:12 -0500 Subject: [PATCH 2/2] Use the same generics as NextPage --- docs/basic-features/layouts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/basic-features/layouts.md b/docs/basic-features/layouts.md index 14ebfdc427939..7d8a773fc886a 100644 --- a/docs/basic-features/layouts.md +++ b/docs/basic-features/layouts.md @@ -125,12 +125,12 @@ import type { ReactElement, ReactNode } from 'react' import type { NextPage } from 'next' import type { AppProps } from 'next/app' -type NextPageWithLayout = NextPage & { +type NextPageWithLayout

= NextPage & { getLayout?: (page: ReactElement) => ReactNode } type AppPropsWithLayout = AppProps & { - Component: NextPageWithLayout + Component: NextPageWithLayout } export default function MyApp({ Component, pageProps }: AppPropsWithLayout) {