When writing JavaScript code, I always comment on my functions as described here , for example:
function add(a, b) {
return a + b;
}
Now, when I write an asynchronous function returning Promise, it will be:
function add(a, b) {
return new Promise(function (resolve, reject) {
resolve(a + b);
});
}
But now the description of the return type ( Promise) skips information about what type of promise will be returned when it is resolved.
How to indicate that the promised promise will be resolved with Number?
I would think that it is Promise.<Number>better (similarly Array.<Number>), but in this area there is no ordinary practice.
source
share