Assuming a generic type below, what should I use in place of ??? to properly document T?
/**
* ??? The description of T.
*/
class MyClass<T> {
}
In C# I'd use <typeparam>. Is there an official JSDoc equivalent?
Assuming a generic type below, what should I use in place of ??? to properly document T?
/**
* ??? The description of T.
*/
class MyClass<T> {
}
In C# I'd use <typeparam>. Is there an official JSDoc equivalent?
VLAZ notes in the comments that @template works but isn't mentioned in the official JSDoc documentation. It is, however, mentioned in Typescript's own JSDoc reference:
You can declare type parameters with the
@templatetag. This lets you make functions, classes, or types that are generic:
Example:
/**
* Description of the class MyClass.
*
* @template T Description of the type parameter T.
*/
class MyClass<T> {
constructor(public readonly x: T) {}
}
The text "Description of the type parameter T." appears in the Typescript Playground when I hover over the occurrence of T in the constructor, so this does seem to work.
If instead of JSDoc you want to use TSDoc, then the tag is @typeParam.
for those who are looking the TsDoc, you can use the https://tsdoc.org/pages/tags/typeparam/
???above?@template T - some description heresee here (it's TS documentation but explains how to annotate JS code) and here is the full description of@template. Annoyingly the JSDoc documentation doesn't mention@template