-
Notifications
You must be signed in to change notification settings - Fork 95
Add JSDoc comments to function calls #189
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
Thanks! In theory yes, I'm all for this. What I don't want is too much of:
Someone did this to the Espruino codebase a while back and been a complete pain - it's just one more thing to maintain and possibly go out if date. Changing existing comments over to Adding types could be handy - do we know if eslint can use those to help with linting? IMO that'd be the real reason for adding them, if it could be used to pick up problems. Don't know how you want to work with this - shall I merge now, or you want to wait until there's more? |
Yeah that was my concern, I can tell it's a pretty elegant low dependency codebase so wasn't sure you'd want an excessive level of fluff, the JS ecosystem can become unnecessarily complex. The This example below shows the new hinting for the It's probably not something ideally suited to linting, I think to get those kinds of type safety checks to make sure correct types are being passed through the whole, you'd probably be best placed making the files full I wouldn't necessarily merge this yet though, it was more to gauge your thoughts, there's places it could help and there's places where yeah it might be more maintenance for you in the long run which I wouldn't want to cause. It did turn up a few things though like here where the input param should actually be an |
Thanks - for Honestly, it sounds like we're on the same wavelength about this - so it's up to you. If it's helpful to you, especially if you're making the changes anyway I'm very happy to merge them in. Thanks for the |
Fantastic 👍🏻 Well if you're happy with the approach, leave this open for now while I work through the rest of the codebase, I'll comment JSdoc where feels appropriate and then I'll ping you once this is out of WIP and see where we're at? |
So as it turns out there is a checkJs option. Enabling it shows 210 errors with typing though 😂 There are definitely some legitimate bugs it turns out but like with the linting it'd be sifting through all the less serious things to find the bugs 🤷🏻♂️ |
Great find - thanks! At some point it'd be good to have the ability to |
I've added it as I've also added Going to call this one ready though in the current state, I don't want to make the diff massive, hopefully most of the changes here are just comments, minor lint fixes or utility stuff and nothing in the actual data path as the code that would make it a risky change. |
Looks great! Thanks for tidying up the Merging now :) |
Apologies if this is too overreaching or not something that's desired. Ended up down a slight tangent. 😄
While working through and understanding the codebase better to learn how to best implement #188 I started to add JSDoc comments to some of the function calls just to make it easier working through call signatures in an editor.
Most of what's there was comment blocks that already existed, just reformatted into a JSDoc type standard so they're picked up along with types expected etc.
Ultimately this can also mean Typescript definitions can be auto generated from the JSdoc comments, if that's something you wanted.
I'll keep this one open and WIP, and if it is something you do want adding I can slow time work through the rest of the call signatures and add to them.