I have Promise.all
that works on all promise<void>
like this
var actionList = new Array<Promise<void>>();
actionList.push(PluginService.InstallExtension(element, en.ExtensionFolder)
.then(function () {
addedExtensions.push(element);
var name = element.publisher + '.' + element.name + '-' + element.version;
//vscode.window.showInformationMessage("Extension " + name + " installed Successfully");
}));
Promise.all(actionList).then(function () {
// all resolved
}).catch(function (e) {
console.error(e);
});
I want to add Promise<boolean>
in actionList
How i can add in typescript?
I have Promise.all
that works on all promise<void>
like this
var actionList = new Array<Promise<void>>();
actionList.push(PluginService.InstallExtension(element, en.ExtensionFolder)
.then(function () {
addedExtensions.push(element);
var name = element.publisher + '.' + element.name + '-' + element.version;
//vscode.window.showInformationMessage("Extension " + name + " installed Successfully");
}));
Promise.all(actionList).then(function () {
// all resolved
}).catch(function (e) {
console.error(e);
});
I want to add Promise<boolean>
in actionList
How i can add in typescript?
Share Improve this question edited Aug 28, 2016 at 17:48 Shan Khan asked Aug 28, 2016 at 15:23 Shan KhanShan Khan 10.4k18 gold badges69 silver badges114 bronze badges1 Answer
Reset to default 5Use a union type on the type parameter and specify that it can be void or a boolean:
var actionList = new Array<Promise<void | boolean>>();
// example of piling code:
actionList.push(new Promise<void>((resolve, reject) => {}));
actionList.push(new Promise<boolean>((resolve, reject) => {}));