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 19, 2022
1 parent d41ca43 commit e0fca68
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions packages/next/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,10 @@ 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
: never
export type InferGetStaticPropsType<T extends (args: any) => any> = Extract<
Awaited<ReturnType<T>>,
{ props: any }
>['props']

export type GetStaticPathsContext = {
locales?: string[]
Expand Down Expand Up @@ -178,16 +175,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
: never
export type InferGetServerSidePropsType<T extends (args: any) => any> = Extract<
Awaited<ReturnType<T>>,
{ props: any }
>['props']

declare global {
interface Crypto {
Expand Down

0 comments on commit e0fca68

Please sign in to comment.