Skip to content

Commit

Permalink
Fix infer next props
Browse files Browse the repository at this point in the history
  • Loading branch information
HaNdTriX committed Sep 17, 2022
1 parent f0ed328 commit 69b0418
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/next/types/index.d.ts
Expand Up @@ -125,12 +125,8 @@ export type GetStaticProps<
context: GetStaticPropsContext<Q, D>
) => Promise<GetStaticPropsResult<P>> | GetStaticPropsResult<P>

export type InferGetStaticPropsType<T> = T extends GetStaticProps<infer P, any>
? P
: T extends (
context?: GetStaticPropsContext<any>
) => Promise<GetStaticPropsResult<infer P>> | GetStaticPropsResult<infer P>
? P
export type InferGetStaticPropsType<T> = T extends GetStaticProps
? Extract<Awaited<ReturnType<T>>, { props: any }>['props']
: never

export type GetStaticPathsContext = {
Expand Down Expand Up @@ -178,15 +174,10 @@ export type GetServerSideProps<
context: GetServerSidePropsContext<Q, D>
) => Promise<GetServerSidePropsResult<P>>

export type InferGetServerSidePropsType<T> = T extends GetServerSideProps<
infer P,
any
>
? P
: T extends (
context?: GetServerSidePropsContext<any>
) => Promise<GetServerSidePropsResult<infer P>>
? P
type Filter<T, U> = T extends U ? T : never

export type InferGetServerSidePropsType<T> = T extends GetServerSideProps
? Extract<Awaited<ReturnType<T>>, { props: any }>['props']
: never

declare global {
Expand Down

0 comments on commit 69b0418

Please sign in to comment.