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

Source code type annotations #331

Closed
toasted-nutbread opened this issue Nov 26, 2023 · 4 comments
Closed

Source code type annotations #331

toasted-nutbread opened this issue Nov 26, 2023 · 4 comments

Comments

@toasted-nutbread
Copy link

Hello, as this project is now under new management, I would like to pose a question: is there interest in having full JSDoc type annotations added for this project? In the Yomichan days, I had started doing some of this, but never actually completed it. I have actually added full type annotations to a copy of the project which is based on a commit about 4 months ago. Seeing as things like #307 have occurred, which is good, it would likely take a bit more work for me to rebase it off the latest code, but I may be able to eventually create a pull request for this.

My initial goal in starting this was to improve project sustainability, as there are many complex types which are difficult to fully understand how they work together, since it's a pure JS project. This could eventually lead to the ability to do a full Typescript conversion if necessary, but that's a different story.

Let me know if you'd like to see this effort continued.

@djahandarie
Copy link
Collaborator

Wow! Great to see you're still around 👀

I would like to pose a question: is there interest in having full JSDoc type annotations added for this project?

Definitely, yes! I agree it would help a lot with maintainability.

I was working on trying to turn on checkJs: true the other day, which is another related but different step to getting towards Typescript, which I think should be the long term vision. Using checkJs does make things annoying (especially enum types in Typescript are hard to use from pure JS), but it does seem like it might be feasible enough to be worth it as an intermediate step.

Let me know if you'd like to see this effort continued.

I would be happy to have whatever you're able to contribute! Feel free to open a draft PR with it, and we can work together on it too. I think the rebase will probably not be too bad, since the switch to ES modules honestly didn't change that much, just the file headers mostly.

@djahandarie
Copy link
Collaborator

@toasted-nutbread I made a draft PR for my attempt to turn on checkJs here: #332

Maybe it'd be good to try and merge your work into that, so that you get the type checking from vscode etc.

Also, there are quite a few things it has caught that seem to be bugs or undefined behavior, or hard-to-tell-what-intent-of-author-was situations. Maybe you'd be able to fix some of those better than I could, so feel free to take a look.

@toasted-nutbread
Copy link
Author

Yes, in the process of updating the codebase, there were numerous things that had to be slightly changed to ensure type safety, and several things should be fixed in the process. A bunch of these it looks like you have already encountered with that PR, but there's a lot more of that once every function has been annotated. The branch I was working on has all of the changes that are made in #332 addressed, so there is probably some redundancy there. I'll try to clean up my work a little bit and get it into a shareable state, which will likely not PR-ready for a while. Be warned that it's currently sitting at a hefty diff of about:

289 files changed, 24921 insertions(+), 5818 deletions(-)

@toasted-nutbread
Copy link
Author

I've created #339, and as promised, it is large.

I'll probably post a few additional thoughts at some point related to some things I noticed while making this update, but I'll do that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants