-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Automatically typed module.required dependencies #1537
Conversation
really like this change |
I also really like this |
LGTM, thank you! I played around with this and tried my best to make some clever use of generics but couldn't figure it out. Hardcoded it is (for now, until LuaCATS generics get better :p). |
Are there any other modules that need to be annotated, or can this be marked as ready? |
Oops, impulsively pressed the button to let the CI run, made the PR "ready" instead. My bad. |
It pretty much is ready and fully functional. I think I managed to type everything but there were some where the class typing was on the module.private so I can update those. Also wasn't 100% unsure on the syntax, not sure if a class or an indexed table etc.. Other than that just fixing the incorrect typings that will pop up but that feels like a separate PR or we can just fix them as we come across them. |
That's interesting, didn't consider the generics route but agree not sure if we're there yet with LuaCATS 😄 |
09654fc
to
4b1a60b
Compare
Ok I believe I got all of them but maybe worth a second pair of eyes, let me know if I missed anything |
Looking good! Thanks again. Guess I'll now have to spend some time looking at the type errors :) |
Did a quick POC for automatic typing of module resolves. Wondering if something like this would be useful to us. Benefit is that doing
local mod = module.required[{dependency}]
mod will be automatically typed with the correct class and will give us luals type hints and typechecks without having to do something like this every time:Type hinting:
It already showed some incorrectly type methods in the codebase
We also get automatic suggestions on which modules can be imported as you can see below:
Downside is obviously that any new added modules will have to be updated in that new
neorg.module.resolver
classThoughts/feedback? @vhyrro @benlubas