Reputation: 691
In C# I can make comments that start /// before the definition of a class or function and these affect the intellisense tips shown when I write code that uses the type or function. But it isn't working in Javascript. Can I get these special comments and extra tips?
Upvotes: 5
Views: 2813
Reputation: 643
For VS 2017+ up to current date of this comment, you need to use JSDoc for TypeScript. {string}
in this example means that param1 is of type string, where "param1" is the name of your parameter. @param
is a necessary keyword to denote that what follows is the intellisense/JSDoc description of the parameter. You would add an "@param
" for each additional parameter in its own line. The text "The first argument to this function" represents what you want intellisense/JSDoc to show as a description for the parameter.
/**
* A description for myFunction.
* @param {string} param1 - The first argument to this function
*/
function myFunction(param1) {
...
}
Upvotes: 5
Reputation: 24558
Not the far, but the comment should be in the js function.
Here is an exemple :
function getArea(radius)
{
/// <summary>Determines the area of a circle that has the specified radius parameter </summary>
/// <param name="radius" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radius * radius;
return areaVal;
}
You will also find HowTo and doc in MSDN.
Upvotes: 3