问题描述
是否可以像下面的示例一样为 JSDoc @param 类型声明使用枚举?
Is it possible to use an enum for the JSDoc @param type declaration like in the following example?
/**
* @enum { Number }
*/
var TYPES = {
TYPE_A: 1,
TYPE_B: 2
}
/**
* @param { TYPES } type
*/
function useTypesEnum( type ) {
}
如果我对 JavaScript 使用 Eclipse 等 IDE,应该不会发出警告?
If I use an IDE like Eclipse etc. for JavaScript, there should no warning be raised?
推荐答案
JsDoc 注释对 JavaScript 代码没有影响.它确实影响的是一些旨在使用该信息的工具.使用 JsDoc 注释的两个工具是 文档生成器 和 Google Closure Compiler.
JsDoc comments have no impact on JavaScript code. What it does influence is some tools designed to use that information. Two of the tools that work with JsDoc comments are the documentation generator and the Google Closure Compiler.
我对 JsDoc3 不是特别熟悉,其中添加了 @enum 标记,但我认为它与任何其他类型一样工作.
I am not particularly familiar with JsDoc3, in which the @enum tag has been added, but i would assume it works just as any other type.
闭包编译器也能正确识别枚举,您可以像示例中提到的那样使用它并获得编译器的所有好处(例如:类型检查).
The Closure Compiler also recognizes the enum correctly and you can use it just like you mentioned in the example and get all the benefits of the compiler (ex: type checking).
这篇关于枚举作为 JSDoc 中的 @param 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)