Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

@auth/drizzle-adapter incompatibility - linkAccount #8283

Closed
thepeterkovacs opened this issue Aug 10, 2023 · 6 comments 路 Fixed by #8294
Closed

@auth/drizzle-adapter incompatibility - linkAccount #8283

thepeterkovacs opened this issue Aug 10, 2023 · 6 comments 路 Fixed by #8294
Labels
drizzle @auth/drizzle-adapter good first issue Good issue to take for first time contributors TypeScript Issues relating to TypeScript

Comments

@thepeterkovacs
Copy link

Question 馃挰

While using the latest version of next-auth (4.22.5) and @auth/drizzle-adapter (0.2.1), the following error occurred in the NextAuthOptions:

Types of property 'linkAccount' are incompatible.

I've set up the minimum required adapter in Postgres according to the documentation.

Here is my code:

import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { SqlFlavorOptions } from "@auth/drizzle-adapter/lib/utils"
import { NextAuthOptions } from "next-auth"
import GithubProvider from "next-auth/providers/github"

import { db } from "@/database/supabase/connection"
import { pgTable } from "@/database/supabase/schema"

export const options: NextAuthOptions = {
        /* the error occurs here */
	adapter: DrizzleAdapter(db as SqlFlavorOptions, pgTable),
	providers: [
		GithubProvider({
			clientId: process.env.GITHUB_CLIENT_ID,
			clientSecret: process.env.GITHUB_CLIENT_SECRET,
		}),
...

Any idea how to resolve this issue?
Thanks in advance!

How to reproduce 鈽曪笍

Follow the documentation for setting up the drizzle adapter with Postgres: https://authjs.dev/reference/adapter/drizzle#drizzleadapter

Contributing 馃檶馃徑

Yes, I am willing to help answer this question in a PR

@thepeterkovacs thepeterkovacs added the question Ask how to do something or how something works label Aug 10, 2023
@github-actions github-actions bot added the drizzle @auth/drizzle-adapter label Aug 10, 2023
@SSardorf
Copy link
Contributor

I outline the issue here, if anyone wants to fix: #8280 (comment)

@balazsorban44 balazsorban44 added TypeScript Issues relating to TypeScript good first issue Good issue to take for first time contributors and removed question Ask how to do something or how something works labels Aug 10, 2023
@balazsorban44
Copy link
Member

balazsorban44 commented Aug 11, 2023

I released a fix in @auth/core, which is a transient dependency of @auth/*-adapter. For it to take effect, you might need to delete node_modules/lock file and reinstall packages.

It's included in @auth/core@0.10.4

If that doesn't work, you can check your package manager's override config, eg. for pnpm adding the following to your package.json should fix the issue:

  "pnpm": {
    "overrides": {
      "@auth/core": "^0.10.4"
    }
  }

@SnekCode
Copy link

SnekCode commented Aug 12, 2023

I released a fix in @auth/core, which is a transient dependency of @auth/*-adapter. For it to take effect, you might need to delete node_modules/lock file and reinstall packages.

It's included in @auth/core@0.10.4

If that doesn't work, you can check your package manager's override config, eg. for pnpm adding the following to your package.json should fix the issue:

  "pnpm": {
    "overrides": {
      "@auth/core": "^0.10.4"
    }
  }

Hello, I'm still experiencing this problem even after installing latest version of auth/core. Attempted doing what you mentioned above with no luck.

I'm implementing a custom adapter where I have imported the types from @auth/adapters. I receive typescript errors when I pass the custom adapter via NextAuthOptions. same errors as above with some others Types of property 'linkAccount' are incompatible.

I really wish next-auth would export their adapter types that would make all of this much easier.

VV made some progress VV

Edit: I was able to side step the type error by defining the type of Adapter as type Adapter = NextAuthOptions['adapter']. This works becuase I'm not using the Adapter type from @auth/core. So I still think there might be a problem here.

Edit 2: @balazsorban44 just saw your comment on this issue so sorry for the extra noise #8280 (comment)

@balazsorban44
Copy link
Member

balazsorban44 commented Aug 12, 2023

If you are importing types from @auth/core/adapters, make sure it's at least the above mentioned version. Otherwise you can keep using next-auth/adapters for your custom one.

Here is the explanation #8294

@SnekCode
Copy link

SnekCode commented Aug 12, 2023

Yup, was using "@auth/core": "^0.11.1",

I don't have an export from next-auth/adapters when using "next-auth": "^4.23.0",

image

@balazsorban44
Copy link
Member

Fixed via 20c3fe3, will release later. 馃檹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drizzle @auth/drizzle-adapter good first issue Good issue to take for first time contributors TypeScript Issues relating to TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants