diff --git a/types/next-auth/client.d.ts b/types/next-auth/client.d.ts index 2d71939b5b..c87c0d469f 100644 --- a/types/next-auth/client.d.ts +++ b/types/next-auth/client.d.ts @@ -25,7 +25,7 @@ interface SessionProvider extends GenericObject { } interface ContextProviderProps { - session: Session; + session: Session | null | undefined; options?: SetOptionsParams; } @@ -43,7 +43,7 @@ interface NextContext { ctx?: { req: IncomingMessage }; } -declare function useSession(): [Session, boolean]; +declare function useSession(): [Session | null | undefined, boolean]; declare function providers(): Promise; declare const getProviders: typeof providers; declare function session( diff --git a/types/next-auth/next-auth-tests.ts b/types/next-auth/next-auth-tests.ts index 9cc127b3e2..d05774089d 100644 --- a/types/next-auth/next-auth-tests.ts +++ b/types/next-auth/next-auth-tests.ts @@ -190,7 +190,7 @@ const session = { expires: '1234', }; -// $ExpectType [Session, boolean] +// $ExpectType [Session | null | undefined, boolean] client.useSession(); // $ExpectType Promise @@ -230,6 +230,28 @@ client.Provider({ }, }); +// $ExpectType ReactElement | null +client.Provider({ + session, +}); + +// $ExpectType ReactElement | null +client.Provider({ + session: undefined, + options: {}, +}); + +// $ExpectType ReactElement | null +client.Provider({ + session: null, + options: { + baseUrl: 'https://foo.com', + basePath: '/', + clientMaxAge: 1234, + keepAlive: 4321, + }, +}); + // -------------------------------------------------------------------------- // Providers // --------------------------------------------------------------------------