From 1ad01b67ea3423be8ba7a93c3cb1c87b97f7db5c Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Fri, 15 Jul 2022 10:43:56 +0200 Subject: [PATCH] Add getStaticPropsContext type --- packages/next/server/app-render.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index ef2e845ddd4f..1e4f6be28f39 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -655,6 +655,17 @@ export async function renderToHTML( pathname: string } + type GetStaticPropsContext = { + layoutSegments: FlightSegmentPath + params?: { [key: string]: string | string[] } + preview?: boolean + previewData?: string | object | undefined + } + + type GetStaticPropContextPage = GetStaticPropsContext & { + pathname: string + } + // TODO-APP: pass a shared cache from previous getStaticProps/getServerSideProps calls? if (layoutOrPageMod.getServerSideProps) { // TODO-APP: recommendation for i18n @@ -681,7 +692,9 @@ export async function renderToHTML( } // TODO-APP: implement layout specific caching for getStaticProps if (layoutOrPageMod.getStaticProps) { - const getStaticPropsContext = { + const getStaticPropsContext: + | GetStaticPropsContext + | GetStaticPropContextPage = { layoutSegments: segmentPath, ...(isPage ? { pathname } : {}), ...(pageIsDynamic ? { params: currentParams } : undefined),