There are a number of things named JSDoc, but using closure compiler annotations which work with jsdoc toolkit, you can use @constructor to mark MyClass as a constructor.
/** @constructor */
var MyClass = ...;
Then you can make it clear that that is of the nominal type MyClass though obviously that nominal type won't work with instanceof.
/** @type MyClass */
var that = /** @type {MyClass} */ {};
The first @type establishes the type of the declaration, and the second is a type assertion/cast for the value.
With the methods you can use the @this annotation.
发布评论
评论(1)
有很多名为 JSDoc 的东西,但使用闭包编译器 与 jsdoc 工具包配合使用的注释,您可以使用
@constructor< /code> 进行标记
MyClass
作为构造函数。然后,您可以清楚地表明
that
属于名义类型MyClass
,但显然该名义类型不适用于instanceof
。第一个
@type
建立声明的类型,第二个是值的类型断言/转换。通过这些方法,您可以使用
@this
注释。There are a number of things named JSDoc, but using closure compiler annotations which work with jsdoc toolkit, you can use
@constructor
to markMyClass
as a constructor.Then you can make it clear that
that
is of the nominal typeMyClass
though obviously that nominal type won't work withinstanceof
.The first
@type
establishes the type of the declaration, and the second is a type assertion/cast for the value.With the methods you can use the
@this
annotation.