I would like to add a description to a js function like I do it in C, C , Python ...
I do this by adding a comment at the top of the definition of the function, in the mentioned languages, but if I use JavaScript (pure, NodeJS, ReactJS) it does not show it. Ej:
Result (When I put the cursor in a call of the function or definition):
But I this behaviour does not replicate with Js/NodeJs/React. Just in case I'm using Visual Studio Code.
CodePudding user response:
VSCode, like most IDEs, will automatically process
You can augment that with types if you want type hints:
/**
* Does something nifty.
*
* @param {number} whatsit The whatsit to use (or whatever).
* @returns {string} A useful value.
*/
function nifty(whatsit) {
return /*...*/;
}
If you use TypeScript, the types would be part of the code rather than in the JSDoc:
// TypeScript example
/**
* Does something nifty.
*
* @param whatsit The whatsit to use (or whatever).
* @returns A useful value.
*/
function nifty(whatsit: number): string {
return /*...*/;
}