I have some code that returns a promise object, e.g. using Q library for NodeJS.
var Q = require(\'q\');
/**
* @returns
There's also another way of doing this even though it might be DEPRECATED. Emphasis on might since someone says it's deprecated (check the comments to that answer) while others say either one is fine. I'm reporting it anyway for the sake of completeness.
Now, take Promise.all()
for example which returns a Promise fulfilled with an array. With the dot notation style it would look like shown below:
{Promise.>}
It works on JetBrains products (e.g. PhpStorm, WebStorm) and it's also used in the jsforce docs.
At the time of writing when I try to auto-generate some docs with PHPStorm it defaults to this style even though I found poor reference to it.
Anyway if you take the following function as an example:
// NOTE: async functions always return a Promise
const test = async () => {
let array1 = [], array2 = [];
return {array1, array2};
};
When I let PhpStorm generate the docs I get this:
/**
* @returns {Promise.<{array1: Array, array2: Array}>}
*/
const test = async () => {
let array1 = [], array2 = [];
return {array1, array2};
};