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): improve events
handlers' types
#1853
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/Bro6i1RYYHGXpXhNwjeir57EwAt5 |
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.
Thank you!
Could you please also update the docs in these places:
https://github.com/nextauthjs/next-auth/blob/main/www/docs/configuration/options.md#description-7
https://github.com/nextauthjs/next-auth/blob/main/www/docs/configuration/events.md
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.
Thanks 💯 , brilliant work; I leave a couple of suggestions 👍🏽
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.
Could you please fix the merge conflicts?
Also my previous comment still stands: #1853 (review) |
Sure thing @balazsorban44 - I was just starting on the code comments before tackling the documentation so I was sure to be documenting my final draft. Will tackle the merge and your code comments and then wrap up the docs changes. |
All comments responded to and documentation updated. |
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.
Just one small thing to prevent conflicts on the documentation 🙏🏽 , thanks a lot for this massive work 💯
@@ -5,7 +5,7 @@ title: Options | |||
|
|||
## Environment Variables | |||
|
|||
### NEXTAUTH_URL | |||
### NEXTAUTH_URL |
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.
Could we revert this file?
I have a PR open updating it extensively and I think it's gonna end a bit in conflict hell 😬 due to the prettier
changes. I'll add the bit you updated pointing to the events
documentation on my PR 👍🏽
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.
In fact, NVM I confused the file name 🤦🏽♂️ ☕️ , ha ha we're all good 💚
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.
💪🏽
@@ -5,7 +5,7 @@ title: Options | |||
|
|||
## Environment Variables | |||
|
|||
### NEXTAUTH_URL | |||
### NEXTAUTH_URL |
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.
In fact, NVM I confused the file name 🤦🏽♂️ ☕️ , ha ha we're all good 💚
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.
Some feedback from me! Please remove the extraneous generics, as we discussed Module Augmentation. Otherwise, it is looking good and will be a nice improvement, so thank you! 🙏
I am also thinking that most of these should be moved to internals/events.d.ts
maybe to keep down the index.d.ts
file size as well. What do you think @lluia?
Resolved merge conflict, updated to main repo's |
Thabk you! About the events, they aren't, you can see it in the source code: See the following lines: 95, 100, 154, 199, 210 those events will only be triggered, if an adapter is used. there is no point in triggering them otherwise. EDIT: Sorry for my quick judgment on this, I'll have a proper look later on from the desktop. Feel free to leave your changes for now, you might be right, I'll get back on this. Thank you for your patience on this! 🙏 |
Ah no worries, it sounds like we're actually reading this the same way @balazsorban44 that those events are sent based on whether or not you have an adapter connected, which as far as I can tell is separate from whether you are using JWTs (since you could configure an adapter and also set But are we now splitting hairs? Let me know if you think that's excessive or not - if not I can restructure the type like that pretty easily. |
Right! I think it's a big improvement anyway, so I'll approve this in its current form, and if for some reason it won't be good enough, we can open a new PR. Thank you for your contribution! 💚 |
events
handlers' message arguments (Resolves #1639)events
handlers' types
@zackdotcomputer sorry, this is the last thing I'll ask, but before merging, could you please fix the failing tests? |
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 are some failing tests
Okay - we'll see how the build goes but that should have fixed it. |
@zackdotcomputer Unfortunately it still fails. I recommend running |
Ah yup my bad @balazsorban44 - I was running the tests but not the lint. Fixed the lint now too - run test is green locally. |
Yeah, we don't really have actual tests at the moment. 🥲. Working on it though! #1937 |
What:
This change introduces typing for the
events
object so that developers using Typescript with next-auth will receiving hinting as to the type of the incoming arguments to events callback functions.Resolves #1639
Why:
Because previously developers didn't have any idea what arguments they'd receive when listening to events even though it was relatively well-defined in the source code.
How:
By analyzing the source code for the possible paths to trigger
events
and then editing the typing files to match the discovered pathways.Checklist: