Với mã này:giá trị như thế nào vào tài liệu giải quyết của JavaScript hứa hẹn
function asyncFoo() {
return new Promise(function (fulfill, reject) {
doAsyncStuff(function(err, data) {
if(err) reject(new Error(err));
else fulfill(new Bar(data));
});
});
}
Làm thế nào tôi có thể ghi nhận rằng asyncFoo
sẽ trả về một Promise
đó, khi hoàn thành sẽ mang lại một thể hiện của Bar
, và khi bị từ chối sẽ mang lại một thể hiện của Error
?
/**
* @return << Here, what do I have to write? >>
*/
function asyncFoo() { ... }
> câu hỏi tương tự để https://stackoverflow.com/questions/13104411/how- to-specified-resolution-and-từ chối-type-of-the-promise-in-jsdoc/46733261 # 46733261 – holmberd