Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsdoc valid param types

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

@param {type} myParam Some parameter description 

I know that things like number and String are valid, but what if I want to document that the number is an integer. Is int valid?

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

like image 900
Jeff Storey Avatar asked Jan 02 '13 23:01

Jeff Storey


People also ask

What is the JSDoc keyword to specify an argument to a function?

The @param tag provides the name, type, and description of a function parameter. The @param tag requires you to specify the name of the parameter you are documenting.

Can you use JSDoc with TypeScript?

You can use most JSDoc type syntax and any TypeScript syntax, from the most basic like string to the most advanced, like conditional types.

What are JSDoc comments?

JSDoc comments are used for documentation lookup with Ctrl+Q in JavaScript and TypeScript, see JavaScript documentation look-up and TypeScript documentation look-up, as well as for type annotations and method return type hints in chained methods.

What is Typedef in JSDoc?

The @typedef tag is useful for documenting custom types, particularly if you wish to refer to them repeatedly. These types can then be used within other tags expecting a type, such as @type or @param. Use the @callback tag to document the type of callback functions.


1 Answers

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.

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:

@param {number} myParam must be an integer

cheers

like image 173
hunterloftis Avatar answered Sep 21 '22 23:09

hunterloftis