Enum as @param type in JSDoc(枚举作为 JSDoc 中的 @param 类型)
问题描述
是否可以像下面的示例一样为 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 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:枚举作为 JSDoc 中的 @param 类型


基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01