Using // comment format for Intellisense

Viewed 684

TL;DR: Where does the JS comment-appending behavior of the VSCode "Editor Hover" box come from and can it be adapted to use // comments?

When editing .js/.ts files, VSCode shows a box when the mouse hovers over any reference to a variable (controlled with the Editor > Hover settings).

/** I'm a comment */
const someVariable = 'Me';

console.log(someVariable);

results in the following when hovering over someVariable in the last line:

Screenshot of a variable showing a comment in the hover.

The comment portion of that box only appears if it is a multi-line comment beginning with two asterisks, one or more lines above a variable, object property, or function, in line with Intellisense's use of JSDoc. Very useful, but some team members prefer to put // comments at the end of a short line where a variable was declared. Is there any way to make VSCode take these end-of-line comments into account for variables/properties, or would I have to convert every relevant comment to /** to see it like this?

1 Answers

This 2 minute video was pretty helpful for me to see the advantages of using the jsDoc format. Instead of Ctrl K Ctrl C in vscode I'm going to start typing /** which autocompletes the comments similar to visual studio code typing /// in c# to autogenerate the comments template, etc. Here's the video: Quickly writing JSDoc comments in JavaScript and TypeScript

Related