I'm trying to return a promise with an .try(function(){}).catch(function(){})
block.
My problem is caused by the type of my promise.
deleteProcess(processId: number): Promise<ProcessInstance> {
let deletedProcess = this.Process.findById(processId);
return Promise
.try(function () {
this.Process.destroy({
where: {
processId: processId
}
})
.then(function (rowDeleted) {
if (rowDeleted === 1) {
console.log('Deleted successfully');
return this.getDeletedProcess();
}
})
.catch(function (err) {
console.log(err);
})
});
function getDeletedProcess(): ProcessInstance {
return this.deletedProcess;
};
};
The error says, that type 'Bluebird void' is not assignable to type 'Bluebird ProcessInstance'