From 47d306b33e5bc3a210d7e467d129eb49b0efccb2 Mon Sep 17 00:00:00 2001 From: misoton665 Date: Wed, 8 Dec 2021 21:12:58 +0900 Subject: [PATCH 1/2] Improve types in server-side withPageAuthRequired --- src/helpers/with-page-auth-required.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/helpers/with-page-auth-required.ts b/src/helpers/with-page-auth-required.ts index 926f5a626..bf32f847e 100644 --- a/src/helpers/with-page-auth-required.ts +++ b/src/helpers/with-page-auth-required.ts @@ -7,6 +7,7 @@ import { WithPageAuthRequiredProps } from '../frontend/with-page-auth-required'; import { withPageAuthRequired as withPageAuthRequiredCSR } from '../frontend'; +import { ParsedUrlQuery } from 'querystring'; /** * If you wrap your `getServerSideProps` with {@link WithPageAuthRequired} your props object will be augmented with @@ -32,7 +33,9 @@ export type GetServerSidePropsResultWithSession

= GetServerSidePropsRes * * @category Server */ -export type PageRoute

= (cts: GetServerSidePropsContext) => Promise>; +export type PageRoute = ( + cts: GetServerSidePropsContext +) => Promise>; /** * If you have a custom returnTo url you should specify it in `returnTo`. @@ -60,8 +63,8 @@ export type PageRoute

= (cts: GetServerSidePropsContext) => Promise = { - getServerSideProps?: GetServerSideProps

; +export type WithPageAuthRequiredOptions

= { + getServerSideProps?: GetServerSideProps; returnTo?: string; }; @@ -85,7 +88,7 @@ export type WithPageAuthRequiredOptions

= { * @category Server */ export type WithPageAuthRequired = { -

(opts?: WithPageAuthRequiredOptions

): PageRoute

; + (opts?: WithPageAuthRequiredOptions): PageRoute;

( Component: ComponentType

, options?: WithPageAuthRequiredCSROptions From 731545957784e825dab723cf5f0ab813ba644d8f Mon Sep 17 00:00:00 2001 From: misoton665 Date: Tue, 28 Dec 2021 15:40:11 +0900 Subject: [PATCH 2/2] Add a default to the type parameter of the server-side WithPageAuthRequrired --- src/helpers/with-page-auth-required.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/with-page-auth-required.ts b/src/helpers/with-page-auth-required.ts index bf32f847e..fbe9cc0a2 100644 --- a/src/helpers/with-page-auth-required.ts +++ b/src/helpers/with-page-auth-required.ts @@ -88,7 +88,7 @@ export type WithPageAuthRequiredOptions

(opts?: WithPageAuthRequiredOptions): PageRoute; + (opts?: WithPageAuthRequiredOptions): PageRoute;

( Component: ComponentType

, options?: WithPageAuthRequiredCSROptions