I have this:
const onUpdate = function (v: string, o: any) : Promise<any> {
const finalName = String(v || '').split('.')[1]; // collection name
const _id = o && o.o2 && o.o2._id;
let key;
switch (finalName) {
case 'categories':
return Category.findOne({_id}).exec().then(function (cat: any) {
// ....
});
case 'acquisitions':
return Acquisition.findOne({_id}).exec().then(function (acq: any) {
// ...
});
case 'functionalTeams':
return FunctionalGroup.findOne({_id}).exec().then(function (ft: any) {
// ...
});
default:
log.error('document collection did not match a pre-defined name');
// nothing is returned here, but can TS check to see if it does/doesn't
}
};
can TypeScript check to see if a Promise fails to be returned in the default or after the switch statement? Right now it's compiling even though a Promise is not returned in all cases.
I have this:
can TypeScript check to see if a Promise fails to be returned in the default or after the switch statement? Right now it's compiling even though a Promise is not returned in all cases.