-
Notifications
You must be signed in to change notification settings - Fork 4k
Migrate to Typescript #516
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
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/jogohcsk7 |
iaincollins
left a comment
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've added a label to note this is pull request is on hold, until after testing and after a core team decision about priorities and where this might fit in.
There is a lot of good stuff in this PR but there are also a number of things in flight merging this would impact and questions regarding what the impact of this would be on-going development.
|
@iaincollins sounds good. I also converted this to a draft. Feel free to ping me here when things merge to master (or I can pull in changes from branches in question too) and make the updates. I just did this for the basecamp change. |
Thanks Nick! Really appreciate it. Letting pull requests go stale is never a good feeling and I appreciate this has happened before.
Once we have some versions of those in place (and either automated publishing of pre-release versions to canary tag or something equivalent) we should be in a much better place to handle refactoring. This is a bug bear for me too as there is a load of stuff I would like to refactor in the oauth code that is knarly and not easy to debug. |
…jb/migrate-to-ts
|
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep ot open. Thanks! |
|
For those who are interested on helping the TypeScript rewrite, where can we start? Recently I tried to rebuild |
|
@grikomsn I have an idea, don't know if it's the best strategy, but it is incremental, can be stretched over many PRs (which are easier to handle, the iteration is faster), and releases, so here it is:
This is good because even if we end up stopping at step 6 because we do not wish to convert everything to TS, we will still have a good type system right next to the codebase. |
|
I am pretty sure this PR won't be merged. If anyone would like to work on TS support, please create a corresponding issue for it, where we can track the progress. Initially, it would maybe even be better to discuss it in the Discussions |
Working off of #220, I took a shot at converting next-auth to typescript.
Todo
onClick), but that means that the signin/signout functions are actually being called with the event object. So what should we type this? Right now I have it as an overloaded function, which allows bothonClick={signIn}andonClick={() => signIn()}as well as provides intellisense on the available providers for the first argumentWhy convert to typescript?
First off, see the linked issue and the discussion about switching there. While there was concern about switching in that issue, I wanted to show that it's not that difficult, and give a prototype to try.
Detached typings are impossible to keep up to date
To help emphasize why this is a good idea and why typings such as the ones referenced in the PR aren't good enough, here is a small subset of the issues with the proposed typings I ran across while doing this transition (please correct me if you see any issues, both here and in code. I'm not too familiar with next-auth v2 yet)
There were several other issues with null checks that I needed to fix as well, but those are less impactful. Most of these would result in incorrect functionality for typescript users.
PageOptions.signinshould bePageOptions.signIn(capital "i")PageOptions.newUsersshould bePageOptions.newUser(no "s")and
Other
we don't need to have a debate about TS vs JS here, but I find it invaluable for documentation and confidence in community changes to have type checking, so I wanted to put this PR together.
A couple other questions I came across while doing the change
Basecamp doesn't look like it exists in code, but it's documented. Am I missing something here?- this is merged now1a. Basecamp doesn't have a scope property, all of the other OAuth providers do. Should it.