-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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): adjust properties on default interfaces #1794
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/6HXZGQSouiGdgdigDUXZrW8JudAG |
🎉 This PR is included in version 3.15.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
accessToken?: string | ||
expires: string | ||
} | ||
export interface Session extends Record<string, unknown>, DefaultSession {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the Session
and JWT
interfaces shouldn’t extend Default{Session,JWT}
as that nullifies the point of this change, unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That worked like charm, thank you! 🙌
🎉 This PR is included in version 4.0.0-next.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix(ts): adjust properties on default interfaces * fix(ts): make expires also optional * fix(ts): don't require default session/jwt fields * fix(ts): make all default fields optional
What:
Adjusting the
JWT
andSession
interfacesWhy:
Here is the shape of the default JWT payload:
next-auth/src/server/routes/callback.js
Lines 86 to 91 in cb1e5a7
Here is the default Session payload:
next-auth/src/server/routes/session.js
Lines 32 to 39 in cb1e5a7
We should make it possible for users to make their own assumptions about the default properties. Currently, because of how type augmentation works, even if you made for example the
user
field required, it would have been shown as optional, because our default said it was optional. By extracting the default session and JWT interfaces, the user will have full control of those interfacesHow:
Checklist:
Thanks to @kripod for the heads-up!