Skip to content

fix: TS Module Augmentation #5556

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 13, 2022
Merged

fix: TS Module Augmentation #5556

merged 7 commits into from
Oct 13, 2022

Conversation

ThangHuuVu
Copy link
Member

@ThangHuuVu ThangHuuVu commented Oct 11, 2022

☕️ Reasoning

This fixes the Module Augmentation issue:

  • Remove | { email: string } part which breaks the Module Augmentation. I don't think we need it for anything 🤔. Matches that type with AdapterUser instead.
  • Added a quick module augmentation in the dev app for easier review, will remove it afterward 🙌

🎫 Affected issues

Fixes: #5542

📌 Resources

Sorry, something went wrong.

@vercel
Copy link

vercel bot commented Oct 11, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
next-auth ✅ Ready (Inspect) Visit Preview Oct 13, 2022 at 2:31AM (UTC)

@github-actions github-actions bot added core Refers to `@auth/core` TypeScript Issues relating to TypeScript labels Oct 11, 2022
@ThangHuuVu ThangHuuVu temporarily deployed to Preview October 11, 2022 17:37 Inactive
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

I believe events and the signIn callback both can receive the user from the database.

@github-actions
Copy link

🎉 Experimental release published 📦️ on npm!

pnpm add next-auth@0.0.0-pr.5556.ac098ce6
yarn add next-auth@0.0.0-pr.5556.ac098ce6
npm i next-auth@0.0.0-pr.5556.ac098ce6

@ThangHuuVu
Copy link
Member Author

ThangHuuVu commented Oct 12, 2022

I believe events and the signIn callback both can receive the user from the database.

That's true, I matched the type of { email: string } to AdapterUser 🙌

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@vercel vercel bot temporarily deployed to Preview October 13, 2022 02:31 Inactive
@ThangHuuVu ThangHuuVu merged commit fe7aaed into main Oct 13, 2022
@ThangHuuVu ThangHuuVu deleted the fix/ts-module-augmentation branch October 13, 2022 02:39
@@ -17,7 +17,7 @@ export interface CredentialsConfig<
authorize: (
credentials: Record<keyof C, string> | undefined,
req: Pick<RequestInternal, "body" | "query" | "headers" | "method">
) => Awaitable<(Omit<User, "id"> | { id?: string }) | null>
Copy link

Choose a reason for hiding this comment

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

@ThangHuuVu We use SERIAL id's as we have a PostgreSQL database coming from v3, the removal of this line triggers a type error as number is not assignable to string.

Copy link

Choose a reason for hiding this comment

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

Do we need to extend the User interface as well? @emrysal

joe1chen pushed a commit to dogomedia/next-auth that referenced this pull request Jan 29, 2025
* commit '462cca1087135ffc89af39f1f4ad6a0007e38f7a':
  chore(release): bump package version(s) [skip ci]
  chore: remove codeql run on main push
  fix(ts): TS Module Augmentation (nextauthjs#5556)
  docs: options.md grammar fixes (nextauthjs#5562)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` providers TypeScript Issues relating to TypeScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module Augmentation doesn't work since last update
4 participants