How to specify resolution and rejection type of the promise in JSDoc?

Even if they don’t exist in Javascript, I found that JSdoc understands “generic types”. So you can define your custom types and then use /* @return Promise<MyType> */. The following result in a nice TokenConsume(token) → {Promise.<Token>} with a link to your custom Token type in the doc. /** * @typedef Token * @property {bool} … Read more

Correct way to document open-ended argument functions in JSDoc

The JSDoc specs and Google’s Closure Compiler do it this way: @param {…number} var_args Where “number” is the type of arguments expected. The complete usage of this, then, would look like the following: /** * @param {…*} var_args */ function lookMaImVariadic(var_args) { // Utilize the `arguments` object here, not `var_args`. } Note the comment about … Read more

How to document a dictionary in JSDoc?

According to the JSDoc 3 docs: Arrays and objects (type applications and record types) An object with string keys and number values: {Object.<string, number>} So it would be: /** @type {{locales: Object.<string, {name: string, lang: string}>}} */ var CONF = { locales: { en: { name: “English”, lang: “en-US” }, es: { name: “Spanish”, lang: … Read more

How to return void in JsDoc?

Closure Compiler According to the documentation of Google’s Closure Compiler if nothing is being returned, the @return annotation should be omitted. If there is no return value, do not use a @return tag. Source: https://developers.google.com/closure/compiler/docs/js-for-compiler#tags jsdoc-toolkit However further documentation also states that the returnType and returnDescription are optional parameters. returnType – Optional: the type of … Read more

How to document a string type in jsdoc with limited possible values

As of late 2014 in jsdoc3 you have the possibility to write: /** * @param {(‘rect’|’circle’|’ellipse’)} shapeType – The allowed type of the shape */ Shape.prototype.getType = function (shapeType) { return this.type; }; Of course this will not be as reusable as a dedicated enum but in many cases a dummy enum is an overkill … Read more

How to specify an array of objects as a parameter or return value in JSDoc?

You should be more specific what you mean by JSDoc – this is a generic term covering pretty much all the JavaDoc-style documentation tools for JavaScript. The syntax you used for array of strings looks like the one supported by Google Closure Compiler. Using this, an array of Objects would be: /** * @param {Array.<Object>} … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)