Reputation: 661
When working on a javascript/typescript project in VSCode, I want to write multi-line code in comment. Knowing that VSCode supports markdown syntax in comment, I go ahead and write:
/**
* ```ts
* { deliverQuestionClicked: { [pageNum]: false } }
* ```
*/
deliverQuestionClicked: {},
However when I hover on that variable, VSCode renders the comment in a ugly looking way:
As the screenshot shown above, there're extra *
that I don't want.
So I wonder what is the correct way to write multi-line code in comment?
I can confirm this problem doesn't exist in VSCode 1.49.1
Code:
class TopRow extends React.Component {
state = {
/**
* ```ts
* { deliverQuestionClicked: { [pageNum]: false } }
* ```
*/
deliverQuestionClicked: {},
};
}
When I hover over that class property, it shows the JSDoc perfectly:
Upvotes: 10
Views: 8918
Reputation: 28633
Must have been fixed.
In VSC 1.48 with this code
class TopRow {
state = {
/**
* ```ts
* { deliverQuestionClicked: { [pageNum]: false } }
* ```
*/
deliverQuestionClicked: {}
}
}
I get
Upvotes: 8
Reputation: 4659
Basic format rules for JSDoc comments.
/**
and end with */
/**
in the first line (with option "check-multiline-start"
)You can optionally specify the option
"check-multiline-start"
to enforce the first line of a multiline JSDoc comment to be empty.
TypeScript in Visual Studio Code
To disable JSDoc comment suggestions in TypeScript,
set"typescript.suggest.completeJSDocs": false
.
To add a comment
Ctrl+Alt+C
twice'Comment code'
from your context menu/**
above the line of code.More info visit
Upvotes: 3
Reputation: 75
Simply Use /* */ before and after the comment. For Example:
/*
This is a multi line comment
I can type on a different line
Without having to worry so far
I close my multi line commen with
an asterix and a backward slash
*/
Upvotes: -3
Reputation: 37
you can use JavaScript's multi-line comment that begins with /* and ends with */. You don't need extra *.
Upvotes: -1