Skip to content

Commit

Permalink
fix: remove unused TS types
Browse files Browse the repository at this point in the history
  • Loading branch information
ThangHuuVu committed Jul 16, 2023
1 parent bd37c55 commit aea27a1
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/next-auth/src/core/lib/email/getUserFromEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default async function getAdapterUserFromEmail({
email: string
adapter: InternalOptions<"email">["adapter"]
}): Promise<AdapterUser> {
// @ts-expect-error -- adapter is checked to be defined in `init`
const { getUserByEmail } = adapter
const adapterUser = email ? await getUserByEmail(email) : null
if (adapterUser) return adapterUser
Expand Down
3 changes: 2 additions & 1 deletion packages/next-auth/src/core/lib/email/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default async function email(
theme,
}),
// Save in database
adapter.createVerificationToken({
// @ts-expect-error -- adapter is checked to be defined in `init`
adapter.createVerificationToken?.({
identifier,
token: hashToken(token, options),
expires,
Expand Down
1 change: 0 additions & 1 deletion packages/next-auth/src/core/routes/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ export default async function callback(params: {

const profile = await getAdapterUserFromEmail({
email: identifier,
// @ts-expect-error -- Verified in `assertConfig`. adapter: Adapter<true>
adapter,
})

Expand Down
4 changes: 2 additions & 2 deletions packages/next-auth/src/core/routes/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fromDate } from "../lib/utils"

import type { Adapter } from "../../adapters"
import type { InternalOptions } from "../types"
import type { ResponseInternal } from ".."
import type { Session } from "../.."
Expand Down Expand Up @@ -98,8 +97,9 @@ export default async function session(
}
} else {
try {
// @ts-expect-error -- adapter is checked to be defined in `init`
const { getSessionAndUser, deleteSession, updateSession } =
adapter as Adapter
adapter
let userAndSession = await getSessionAndUser(sessionToken)

// If session has expired, clean up the database
Expand Down
1 change: 0 additions & 1 deletion packages/next-auth/src/core/routes/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default async function signin(params: {

const user = await getAdapterUserFromEmail({
email,
// @ts-expect-error -- Verified in `assertConfig`. adapter: Adapter<true>
adapter: options.adapter,
})

Expand Down
4 changes: 2 additions & 2 deletions packages/next-auth/src/core/routes/signout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Adapter } from "../../adapters"
import type { InternalOptions } from "../types"
import type { ResponseInternal } from ".."
import type { SessionStore } from "../lib/cookie"
Expand Down Expand Up @@ -28,7 +27,8 @@ export default async function signout(params: {
}
} else {
try {
const session = await (adapter as Adapter).deleteSession(sessionToken)
// @ts-expect-error -- adapter is checked to be defined in `init`
const session = await adapter.deleteSession(sessionToken)
// Dispatch signout event
// @ts-expect-error
await events.signOut?.({ session })
Expand Down
5 changes: 1 addition & 4 deletions packages/next-auth/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ export type AuthAction =
/** @internal */
export interface InternalOptions<
TProviderType = ProviderType,
WithVerificationToken = TProviderType extends "email" ? true : false
> {
providers: InternalProvider[]
/**
Expand All @@ -603,9 +602,7 @@ export interface InternalOptions<
pages: Partial<PagesOptions>
jwt: JWTOptions
events: Partial<EventCallbacks>
adapter: WithVerificationToken extends true
? Adapter<WithVerificationToken>
: Adapter<WithVerificationToken> | undefined
adapter?: Adapter
callbacks: CallbacksOptions
cookies: CookiesOptions
callbackUrl: string
Expand Down

1 comment on commit aea27a1

@vercel
Copy link

@vercel vercel bot commented on aea27a1 Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.