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.
Playground Link
If instead of JSDoc you want to use TSDoc, then the tag is @typeParam.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With