错误 TS2339:属性 'auth' 在类型 'AngularFireAuth' 上不存在

error TS2339: Property 'auth' does not exist on type 'AngularFireAuth'

所以我正在开发我的 ionic4 应用程序并在 try-catch 块中的 auth 上遇到错误。我尝试安装 firebase 包并添加 auth 导入,但似乎没有任何效果。可能是什么问题?

import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { Auth } from 'firebase';

@Injectable({
  providedIn: 'root'
})
export class FirebaseAuthService {
  auth: any[];

  constructor(private angularFireAuth: AngularFireAuth) { }

  async registerWithEmailPassword(email, password) {
    try {
      const result = await this.angularFireAuth.auth.createUserWithEmailAndPassword(email, password);
      await this.angularFireAuth.auth.currentUser.sendEmailVerification();
      return result;
    } catch (error) {
      throw new Error(error);
    }
  }
}

使用最新的 AngularFireAuth,您不再需要指定 .auth。

可以直接访问angularFireAuth.currentUser获取用户信息