Reusable inferSSRProps

pull/2803/head
zomars 2022-05-17 16:01:58 -06:00
parent 4fa380d7ed
commit 98d7d7a11c
1 changed files with 11 additions and 0 deletions

11
packages/types/inferSSRProps.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
type GetSSRResult<TProps> =
//
{ props: TProps } | { redirect: any } | { notFound: boolean };
type GetSSRFn<TProps> = (...args: any[]) => Promise<GetSSRResult<TProps>>;
export type inferSSRProps<TFn extends GetSSRFn<any>> = TFn extends GetSSRFn<infer TProps>
? NonNullable<TProps>
: never;