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

Already on GitHub? Sign in to your account

fix(ts): make User interface overridable using module augmentation #12472

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

comxd
Copy link
Contributor

@comxd comxd commented Jan 6, 2025

☕️ Reasoning

It's not possible to use TS module augmentation to force defined properties as required (i.e., not undefined) for the User interface using next-auth v5.

Usage:

// file types/next-auth.d.ts

declare module "next-auth" {
  interface User {
    id: string;
  }
}

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Related commits:

@comxd comxd requested a review from ubbe-xyz as a code owner January 6, 2025 12:14
Copy link

vercel bot commented Jan 6, 2025

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

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 0:20am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2025 0:20am

Copy link

vercel bot commented Jan 6, 2025

@comxd is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@chungweileong94
Copy link
Contributor

It doesn't seems to work tho.
image

@comxd
Copy link
Contributor Author

comxd commented Jan 6, 2025

It doesn't seems to work tho.

Your module augmentation is declared into a ".d.ts" or a ".ts" file?

@chungweileong94
Copy link
Contributor

It doesn't seems to work tho.

Your module augmentation is declared into a ".d.ts" or a ".ts" file?

I'm using .ts

@comxd
Copy link
Contributor Author

comxd commented Jan 6, 2025

@chungweileong94 Try do define your augmentation into a .d.ts

@balazsorban44 balazsorban44 merged commit 7772375 into nextauthjs:main Jan 7, 2025
6 of 7 checks passed
@comxd comxd deleted the patch-2 branch January 7, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants