<commit_before>import * as firebase from "../../firebase";
import { FirebaseEmailLinkActionCodeSettings, LoginType, User } from "../../firebase";

export module auth {
  export class Auth {
    private authStateChangedHandler;
    public currentUser: User;

    public onAuthStateChanged(handler: (user: User) => void): void {
      this.authStateChangedHandler = handler;
      console.log(">> added onAuthStateChanged handler");
    };

    public signOut(): Promise<any> {
      return new Promise((resolve, reject) => {
        firebase.logout()
            .then(() => {
              this.currentUser = undefined;
              this.authStateChangedHandler && this.authStateChangedHandler();
              resolve();
            })
            .catch(err => {
              reject({
                // code: "",
                message: err
              });
            });
      });
    }

    public signInWithEmailAndPassword(email: string, password: string): Promise<any> {
      return new Promise((resolve, reject) => {
        firebase.login({
          type: LoginType.PASSWORD,
          passwordOptions: {
            email: email,
            password: password
          }
        }).then((user: User) => {
          this.currentUser = user;
          this.authStateChangedHandler && this.authStateChangedHandler(user);
          resolve({
            additionalUserInfo: user.additionalUserInfo,
            credential: null,
            operationType: "SignIn",
            user: user,
          });
        }, (err => {
          {
            let code = 'auth/exception';
            let message = err.toString();
            // Identify code for android. Note that the IOS implementation doesn't return a code.
            if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidCredentialsException')) {
              code = 'auth/wrong-password';
            } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
              code = 'auth/user-not-found';
            // Note that Android returns one exception for both user not found and invalid email whereas
            // the web api returns seperate codes. Therefore the conditional below can never be satisfied
            // for android.
            // } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
            //   code = 'auth/invalid-email'
          }
          reject({
            code: code,
            message: message,
          });
        }));
      });
    }
<commit_msg>TS compile error fixed<commit_after>import * as firebase from "../../firebase";
import { FirebaseEmailLinkActionCodeSettings, LoginType, User } from "../../firebase";

export module auth {
  export class Auth {
    private authStateChangedHandler;
    public currentUser: User;

    public onAuthStateChanged(handler: (user: User) => void): void {
      this.authStateChangedHandler = handler;
      console.log(">> added onAuthStateChanged handler");
    };

    public signOut(): Promise<any> {
      return new Promise((resolve, reject) => {
        firebase.logout()
            .then(() => {
              this.currentUser = undefined;
              this.authStateChangedHandler && this.authStateChangedHandler();
              resolve();
            })
            .catch(err => {
              reject({
                // code: "",
                message: err
              });
            });
      });
    }

    public signInWithEmailAndPassword(email: string, password: string): Promise<any> {
      return new Promise((resolve, reject) => {
        firebase.login({
          type: LoginType.PASSWORD,
          passwordOptions: {
            email: email,
            password: password
          }
        }).then((user: User) => {
          this.currentUser = user;
          this.authStateChangedHandler && this.authStateChangedHandler(user);
          resolve({
            additionalUserInfo: user.additionalUserInfo,
            credential: null,
            operationType: "SignIn",
            user: user,
          });
        }).catch(err => {
          let code = 'auth/exception';
          let message = err.toString();
          // Identify code for android. Note that the IOS implementation doesn't return a code.
          if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidCredentialsException')) {
            code = 'auth/wrong-password';
          } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
            code = 'auth/user-not-found';
            // Note that Android returns one exception for both user not found and invalid email whereas
            // the web api returns seperate codes. Therefore the conditional below can never be satisfied
            // for android.
            // } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
            //   code = 'auth/invalid-email'
          }
          reject({
            code: code,
            message: message
          })
        });
      });
    }

{'fraction_non_alphanumeric': 0.11215502055196712, 'fraction_numerical': 0.0, 'mean_word_length': 1.8563443264393515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2719947', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1235, 'n_words': 315}