Angularfire2错误TS2304:找不到名字'firebase'

问题描述 投票:0回答:1

我尝试提供服务时,我的身份验证服务会抛出此错误

错误TS2304:找不到名称'firebase'。

当我尝试在生产模式下构建它时抛出此错误消息时也会发生这种情况:

错误TS2339:属性'firebase'在类型'{production:boolean; }”。

我正在使用“angularfire2”:“^ 5.0.0-rc.6”和“firebase”:“4.10.1”

这是我的身份验证服务:

import { Injectable } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from '@firebase/app';
import { Observable } from 'rxjs/Observable';
import { Router } from '@angular/router';
import {MatSnackBar} from '@angular/material';

@Injectable()
export class AuthentificationService {
  user: Observable<firebase>;

  constructor(private firebaseAuth: AngularFireAuth, private router: Router,
    public snackBar: MatSnackBar) {
    // authentification initialisation
    this.user = firebaseAuth.authState;
  }

  // login
  login(email: string, password: string) {
    this.firebaseAuth
      .auth
      .signInWithEmailAndPassword(email, password)
      .then(value => {
        console.log('Nice, it worked!');
        this.snackBar.open('Connection réussie', 'OK', {
          duration : 500
        });
        this.router.navigate(['/dataP']);
      })
      .catch(err => {
        console.log('Something went wrong:', err.message);
        this.snackBar.open('Echec de la connection', 'OK', {
          duration : 500
        });
      });
  }

  // logout
  logout() {
    this.firebaseAuth
      .auth
      .signOut();
  }

}

关于如何解决这个问题的任何想法?

angular firebase firebase-authentication angularfire2
1个回答
1
投票

我想出了如何解决这个问题我只是将user: Observable<firebase>;改为user: Observable<firebase.User>;而且我已经没有错误了

© www.soinside.com 2019 - 2024. All rights reserved.