-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 JSDOC @module support for intellisense. #30744
Comments
Also, quite annoyingly, the module doc comment is shown for the first member: |
I would like to give this thread a friendly bump to help determine the current status of support plans for this tag. Since we are currently working on stabilizing the experimental module loader API, this knowledge is relevant to the Node.js Modules Team (of which I am an observer) due to its potential as in-band solution for determining a module's format prior to its loading. If I understand correctly, VS Code uses the TypeScript parser to parse its JavaScript implementation of JSDoc features. In the newest Insiders version of VS Code (possibly older versions as well), the Derived from the official JSDoc page:
I believe the square brackets mean optional and the parser should not be using that for tokenization. Relevant links: |
It would really great if we could enforce a type for a module. A module is similar to an /**
* @typedef NumberValueModule
* @prop {number} value
*/ goodModule.js: /** @module {NumberValueModule} piModule */
export const value = 3.14; badModule.js: /** @module {NumberValueModule} helloModule */
export const value = 'hello';
// ^ this should be reported as the wrong type Is this possible at the moment with |
This would be very helpful for Node.js functional programmers. Modules should work just like classes, where intellisense infers the type from the code. If you aren't using classes, you are doing double work to define type in the code and then again in JSDoc. It's too easy for these definitions to get out of sync. Please do for modules what was done for classes. Whether based on modules or not, bottom line is to support type inference from code that extends beyond classes to any object or function. |
Would you be able to provide a code sample illustrating this? I feel like I'm the only person who uses this convention (even without any tooling benefits). It helps me to keep organized is all. |
connect-stream.js /**
* @param {import('stream').Readable} in
* @param {import('stream').Writable} out
*/
export async function connectStream(in, out) {
in.pipe(out)
} detect-fighting.js /**
* @param {import('stream').Readable} lidar
* @param {import('stream').Writable} infer
* @param {import('./connect-stream').connectStream} cb
*/
async function detectFighting(lidar, infer, cb) {
cb (
lidar.getReadableStream('camera10'),
infer.getWritableStream('fighting')
)
} The jsdoc of the 3rd param in |
Search Terms
Intellisense jsdoc support for modules
Suggestion
When adding
/** @module moduleName Module Description. */
to a module, then doing this:I think it makes sense, when importing the whole namespace, to include the jsdoc
@module
comment.I also think that when pressing Ctrl+Space for code completion on
"./"
(to get a list of modules) should also show the module documentation.Use Cases
Better support for module documentation. I'm developing some module libraries and it would be great to give end users a good experience with better intellisense documentation.
Examples
aModule.ts
app.ts
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: