我们正在 ionic 2 平台上开发一个开源应用程序,有人将 Firebase 添加到项目中,我提出了拉取请求,现在当我尝试运行该应用程序时,我收到此错误。它可能与某些 Firebase 依赖项或包有关。我该如何解决这个问题?
几乎与Firebase相关的每行都会给出此错误。例如:
export declare function _getAuthBackend(app: firebase.app.App): FirebaseSdkAuthBackend;
这是代码:
import * as firebase from 'firebase';
import { Observable } from 'rxjs/Observable';
export declare abstract class AuthBackend {
abstract authWithCustomToken(token: string): Promise<FirebaseAuthState>;
abstract authAnonymously(options?: any): Promise<FirebaseAuthState>;
abstract authWithPassword(credentials: EmailPasswordCredentials): Promise<FirebaseAuthState>;
abstract authWithOAuthPopup(provider: AuthProviders, options?: any): Promise<firebase.auth.UserCredential>;
abstract authWithOAuthRedirect(provider: AuthProviders, options?: any): Promise<void>;
abstract authWithOAuthToken(credentialsObj: firebase.auth.AuthCredential, options?: any): Promise<FirebaseAuthState>;
abstract onAuth(): Observable<FirebaseAuthState>;
abstract getAuth(): FirebaseAuthState;
abstract unauth(): Promise<void>;
abstract createUser(credentials: EmailPasswordCredentials): Promise<FirebaseAuthState>;
abstract getRedirectResult(): Observable<firebase.auth.UserCredential>;
}
export declare enum AuthProviders {
Github = 0,
Twitter = 1,
Facebook = 2,
Google = 3,
Password = 4,
Anonymous = 5,
Custom = 6,
}
export declare enum AuthMethods {
Popup = 0,
Redirect = 1,
Anonymous = 2,
Password = 3,
OAuthToken = 4,
CustomToken = 5,
}
export interface AuthConfiguration {
method?: AuthMethods;
provider?: AuthProviders;
scope?: string[];
}
export interface FirebaseAuthState {
uid: string;
provider: AuthProviders;
auth: firebase.User;
expires?: number;
github?: firebase.UserInfo;
google?: firebase.UserInfo;
twitter?: firebase.UserInfo;
facebook?: firebase.UserInfo;
anonymous?: boolean;
}
export declare function authDataToAuthState(authData: firebase.User, providerData?: firebase.UserInfo): FirebaseAuthState;
export declare function stripProviderId(providerId: string): string;
export interface EmailPasswordCredentials {
email: string;
password: string;
}
可能缺少以下任何配置步骤。
- 将
firebase
添加到tsconfig
中的类型数组 -
在模块中导入
import { AngularFireModule } from 'angularfire2'; @NgModule({ declarations: [...], imports: [ ..., AngularFireModule.initializeApp(firebaseConfig) ], ...
3.您可能需要运行
typings install
注意:-
const firebaseConfig = {
apiKey: "<your-key>",
authDomain: "<your-project-authdomain>",
databaseURL: "<your-database-URL>",
storageBucket: "<your-storage-bucket>"
}