假设下面有一个通用类型,我应该使用什么来代替???正确记录T?
/**
* ??? The description of T.
*/
class MyClass<T> {
}
Run Code Online (Sandbox Code Playgroud)
在 C# 中我会使用<typeparam>. 是否有官方 JSDoc 等效版本?
kay*_*ya3 13
VLAZ 在注释中指出该方法@template有效,但官方 JSDoc 文档中未提及。然而,Typescript 自己的 JSDoc 参考(链接)中提到了这一点:
您可以使用标签声明类型参数
@template。这使您可以创建通用的函数、类或类型:
例子:
/**
* Description of the class MyClass.
*
* @template T Description of the type parameter T.
*/
class MyClass<T> {
constructor(public readonly x: T) {}
}
Run Code Online (Sandbox Code Playgroud)
文本“类型参数 T 的描述”。当我将鼠标悬停在构造函数中的出现位置上时T,它会出现在 Typescript Playground 中,所以这似乎确实有效。
| 归档时间: |
|
| 查看次数: |
2849 次 |
| 最近记录: |