Javascript jsdoc 有效的参数类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14130679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 15:48:05  来源:igfitidea点击:

jsdoc valid param types

javascriptjsdoc

提问by Jeff Storey

Is there a list somewhere of valid types for param tags for jsdoc? For example,

是否有 jsdoc 的 param 标签的有效类型列表?例如,

@param {type} myParam Some parameter description

I know that things like numberand Stringare valid, but what if I want to document that the number is an integer. Is intvalid?

我知道像number和这样的东西String是有效的,但是如果我想记录这个数字是一个整数怎么办。是否int有效?

I've done some googling, but I can't seem to find a full list.

我已经做了一些谷歌搜索,但我似乎无法找到完整的列表。

采纳答案by hunterloftis

The JS Documentation tooling I've used just tokenizes the comments into strings anyway, making it possible to put anything you want in the {type} section.

无论如何,我使用的 JS 文档工具只是将注释标记为字符串,从而可以将您想要的任何内容放入 {type} 部分。

You could stick with JavaScript types if you wanted like {number} or {string}, or if you want to specify you could do {integer}... but I would probably recommend something like:

如果你想要 {number} 或 {string},或者如果你想指定你可以做 {integer},你可以坚持使用 JavaScript 类型……但我可能会推荐类似的东西:

@param {number} myParam must be an integer

@param {number} myParam must be an integer

cheers

干杯

回答by Gyuri

To answer the actual question

回答实际问题

Is there a list somewhere of valid types for param tags for jsdoc?

是否有 jsdoc 的 param 标签的有效类型列表?

The documentation of @paramstates herethat you can use built-in types and "namepaths" (a.k. paths to types you have created/documented earlier and your own types you declared with @type.

的文档@param状态在这里,您可以使用内置的类型和“ namepaths”(AK路径前面的叙述已创建类型/和你自己的类型你声明@type

If you look up built-in Javascript types, you get the following, for example here, you get the list of primitive types:

如果你查找built-in Javascript types,你会得到以下内容,例如在这里,你会得到原始类型的列表:

  • Boolean
  • Null
  • Undefined
  • Number
  • String
  • Symbol (new in ECMAScript 2015)
  • Object
  • 布尔值
  • 空值
  • 不明确的
  • 数字
  • 细绳
  • 符号(ECMAScript 2015 中的新功能)
  • 目的

And here are some examples of namepaths:

以下是名称路径的一些示例:

  • exampleFunction
  • exampleClass#someInstanceMember
  • exampleClass.staticMember
  • exampleClass~innerMember
  • 示例函数
  • 示例类#someInstanceMember
  • exampleClass.staticMember
  • exampleClass~innerMember

E.g. @param {exampleClass} exampleParam Instance of your example class

例如 @param {exampleClass} exampleParam Instance of your example class