[英]Angularfire2 error TS2304: Cannot find name 'firebase'
我嘗試提供驗證服務時會拋出此錯誤
錯誤TS2304:找不到名稱“ firebase”。
當我嘗試在生產模式下構建它並拋出以下錯誤消息時,也會發生這種情況:
錯誤TS2339:類型'{production:boolean;類型不存在屬性'firebase'。 }”。
我正在使用“ 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();
}
}
關於如何解決這個問題的任何想法?
我想出了解決這個問題的方法,我只是更改了user: Observable<firebase>;
給user: Observable<firebase.User>;
而且我沒有錯誤了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.