From e0fca68888b90ed0a25bac3ec3a6807e7721e219 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Sat, 17 Sep 2022 12:19:03 +0200 Subject: [PATCH] Fix infer next props --- packages/next/types/index.d.ts | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 25b63fe2553316..0fb19548967310 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -125,13 +125,10 @@ export type GetStaticProps< context: GetStaticPropsContext ) => Promise> | GetStaticPropsResult

-export type InferGetStaticPropsType = T extends GetStaticProps - ? P - : T extends ( - context?: GetStaticPropsContext - ) => Promise> | GetStaticPropsResult - ? P - : never +export type InferGetStaticPropsType any> = Extract< + Awaited>, + { props: any } +>['props'] export type GetStaticPathsContext = { locales?: string[] @@ -178,16 +175,10 @@ export type GetServerSideProps< context: GetServerSidePropsContext ) => Promise> -export type InferGetServerSidePropsType = T extends GetServerSideProps< - infer P, - any -> - ? P - : T extends ( - context?: GetServerSidePropsContext - ) => Promise> - ? P - : never +export type InferGetServerSidePropsType any> = Extract< + Awaited>, + { props: any } +>['props'] declare global { interface Crypto {