Can an asynchronous IIFE be used inside the callback function to avoid the error message "Promise returned in function argument where a void return was expected"? You can find an example here.
signIn(email: string, password: string, course?: ICourse): Promise<void> {
return new Promise<UserCredential>((resolve, reject) =>
this.afAuth.signInWithEmailAndPassword(email, password).then(
(res) => {
resolve(res);
},
(error: { message: string }) => {
reject(error);
this.toastrService.warning('Something has gone wrong. Please try again.', 'Oops!');
this.logger.debug('An error occurred during Email Sign In');
this.logger.error(error.message);
}
)
).then(
(result: UserCredential) => {
if (course && result.user) {
this.builderSignIn(course, result.user.uid);
} else {
if (result != null) {
this.ngZone.run(() => {
void this.router.navigate(['dashboard']);
});
}
}
},
(error: { message: string }) => {
this.toastrService.warning(error.message, 'Oops!');
}
);
}