-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Add more precise types in the JSDoc #818
Conversation
The failing tests seem unrelated to my PR. I'm changing only comments |
hmm, looks like the jsdoc parser of eslint does not like the object types defining properties. And given that the @Lyrkan @weaverryan should we disable that rule ? |
Or maybe we should migrate to https://github.com/gajus/eslint-plugin-jsdoc |
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.
Sorry for not looking at this sooner, those are some great changes :)
@Lyrkan @weaverryan should we disable that rule ?
Or maybe we should migrate to gajus/eslint-plugin-jsdoc
We could try gajus/eslint-plugin-jsdoc
but I wouldn't mind disabling valid-jsdoc
entirely either tbh.
My preference would be to remove our |
@Lyrkan @weaverryan I made the migration to eslint-plugin-jsdoc (and I fixed all the extra things it reports, which were not detected by |
The failure for the job |
Hey, what about using TypeScript to check types? |
@Kocal using typescript to check types on our own codebase could be a next step after that. But it would require having types defined properly for all our code, while this PR was focusing on what impacts our public API. I should definitely revive that PR as it would be a nice addition. |
@stof you're right, that makes sense.
Totally! :) |
5088cca
to
f41dda2
Compare
I updated the PR (it will conflict with #1313 though). I used I also kept |
This documents the value type for arrays of strings in arguments.
webpack provides type definitions for their whole API, so we can reference their type rather than specifying a generic "object" type. Referencing the webpack types was already done for the returned configuration.
Most of them are documented as receiving an object and returning an object or void. But some callbacks dealing with parts of the webpack configuration itself have a more precise type for the options object.
This brings the list of supported options in the type definitions with their type, which lets IDEs provide autocompletion for them.
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.
Wow 🤩
That's will definitely increase DX for end-users and for us, just a minor comment tho
lib/utils/package-up.js
Outdated
@@ -16,13 +16,17 @@ const { fileURLToPath } = require('url'); | |||
/** | |||
* Inlined version of the package "package-up" (ESM only). | |||
* | |||
* @param {string} cwd The directory to start searching from. | |||
* @param {{cwd: string}} options The directory to start searching from. |
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.
Shouldn't we keep the previous syntax? Here the description "The directory (...)" refers to the options
object, and not to cwd
right?
Or we can remove the description, since it's super internal, I don't really have a strong opinion on this.
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.
The previous syntax describes a cwd
argument which does not exist (there is a cwd
property in the first argument instead).
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 updated the JSDoc to use the alternative syntax allowing to put a description on properties (this was already used later in the file)
These are the type improvements coming from my investigation in #816 (and then pushed until the end rather than stopping at a few methods for the experiment)