@typescript-eslint/no-misused-promises error with Firebase signInWithEmailAndPassword method call

  angular, eslint, firebase, typescript

I am getting the following ESLint warning in my code:

ESLint: Promise returned in function argument where a void return was expected.(@typescript-eslint/no-misused-promises)

I am not sure how to deal with it, it’s been recently picked up ESLint in my recent migration from TSLint.

  signIn(email: string, password: string, course?: ICourse): Promise<void> {
    // ESLint: Promise returned in function argument where a void return was expected.(@typescript-eslint/no-misused-promises)
    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!');
      }
    );
  }

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.