From 91a681993a1431613ae095cb3cdcee59b1a7cd66 Mon Sep 17 00:00:00 2001 From: nbifrye Date: Mon, 15 Jan 2024 19:13:12 +0900 Subject: [PATCH 1/2] fix types --- packages/core/src/types.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 8cb5232f0e..0922b3ace7 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -248,18 +248,13 @@ export interface CallbacksOptions

{ * @see [`jwt` callback](https://authjs.dev/reference/core/types#jwt) */ session: ( - params: ( - | { - session: Session - /** Available when {@link AuthConfig.session} is set to `strategy: "database"`. */ - user: AdapterUser - } - | { - session: Session - /** Available when {@link AuthConfig.session} is set to `strategy: "jwt"` */ - token: JWT - } - ) & { + params: { + session: Session + /** Available when {@link AuthConfig.session} is set to `strategy: "database"`. */ + user?: AdapterUser + /** Available when {@link AuthConfig.session} is set to `strategy: "jwt"` */ + token?: JWT + } & { /** * Available when using {@link AuthConfig.session} `strategy: "database"` and an update is triggered for the session. * From 5f9faba444406f519e6a31539ea76dbe02f7a96a Mon Sep 17 00:00:00 2001 From: nbifrye Date: Wed, 17 Jan 2024 20:46:54 +0900 Subject: [PATCH 2/2] remove unnecessary @ts-expect-error --- packages/next-auth/src/lib/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/next-auth/src/lib/index.ts b/packages/next-auth/src/lib/index.ts index a9410ac4f1..e7aa883712 100644 --- a/packages/next-auth/src/lib/index.ts +++ b/packages/next-auth/src/lib/index.ts @@ -76,7 +76,6 @@ async function getSession(headers: Headers, config: NextAuthConfig) { const session = // If the user defined a custom session callback, use that instead (await config.callbacks?.session?.(...args)) ?? args[0].session - // @ts-expect-error either user or token will be defined const user = args[0].user ?? args[0].token return { user, ...session } satisfies Session },