“ FirebaseApp”类型中缺少“性能”

时间:2019-05-01 20:20:01

标签: javascript angular firebase ionic-framework angularfire2

我正在尝试在我的应用程序中连接Firebase,但是我遇到了同样的错误,我尝试了很多方法,但是没有一个起作用。 首先,我安装了firebase和@ angular / fire

npm install firebase @angular/fire --save

之后,我将environment.ts更改为

export const environment = {
  production: false,
  firebase: {
    apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXX",
    authDomain: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    databaseURL: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    projectId: "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    storageBucket: "XXXXXXXXXXXXXXXXXXXXXXXXX",
    messagingSenderId: "XXXXXXXXXXXXXXXXXXXX"
  }
};

如文档所述。 (我放了XX,但在真实环境中。请放正确的XX)。然后,我将app.module.ts更改为

import { NgModule } from '@angular/core';
...
import { AngularFireModule } from '@angular/fire';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
  AngularFireModule.initializeApp(environment.firebase, 'guarnice')],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

运行代码后

ionic serve

我遇到了错误。

  

node_modules/@angular/fire/firebase.app.module.d.ts(17,22)中的错误:错误TS2420:“ FirebaseApp”类错误地实现了“ App”接口。   类型“ FirebaseApp”中缺少属性“性能”。

然后我寻找了firebase.app.module.d.ts

import { InjectionToken } from '@angular/core';
import { app, auth, database, firestore, functions, messaging, storage } from 'firebase/app';
export declare type FirebaseOptions = {
    [key: string]: any;
};
export declare type FirebaseAppConfig = {
    [key: string]: any;
};
export declare const FirebaseOptionsToken: InjectionToken<FirebaseOptions>;
export declare const FirebaseNameOrConfigToken: InjectionToken<string | FirebaseAppConfig | undefined>;
export declare type FirebaseDatabase = database.Database;
export declare type FirebaseAuth = auth.Auth;
export declare type FirebaseMessaging = messaging.Messaging;
export declare type FirebaseStorage = storage.Storage;
export declare type FirebaseFirestore = firestore.Firestore;
export declare type FirebaseFunctions = functions.Functions;
export declare class FirebaseApp implements app.App {
    name: string;
    options: {};
    auth: () => FirebaseAuth;
    database: (databaseURL?: string) => FirebaseDatabase;
    messaging: () => FirebaseMessaging;
    storage: (storageBucket?: string) => FirebaseStorage;
    delete: () => Promise<void>;
    firestore: () => FirebaseFirestore;
    functions: (region?: string) => FirebaseFunctions;
}
export declare function _firebaseAppFactory(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppConfig | null): FirebaseApp;
export declare class AngularFireModule {
    static initializeApp(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppConfig): {
        ngModule: typeof AngularFireModule;
        providers: {
            provide: InjectionToken<string | FirebaseAppConfig | undefined>;
            useValue: string | FirebaseAppConfig | undefined;
        }[];
    };
}

我不知道该如何解决...我在stackoverflow和其他站点中看到了一些小技巧,但是它们都不起作用。

这是我遵循的文档https://github.com/angular/angularfire2

Angular CLI: 7.3.8
Node: 10.15.3
OS: linux x64
Angular: 7.2.13
Ionic: 4.12.0

 Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.4
@angular-devkit/build-angular     0.13.8
@angular-devkit/build-optimizer   0.13.8
@angular-devkit/build-webpack     0.13.8
@angular-devkit/core              7.2.4
@angular-devkit/schematics        7.2.4
@angular/cli                      7.3.8
@angular/fire                     5.1.2
@ngtools/webpack                  7.3.8
@schematics/angular               7.3.8
@schematics/update                0.13.8
rxjs                              6.4.0
typescript                        3.1.6
webpack                           4.29.0

1 个答案:

答案 0 :(得分:3)

firebaser here

更新:此问题已在AngularFire2 release 5.1.3中修复。升级到此版本可解决此问题。


用于JavaScript的5.11.0 Firebase SDK版本,引入了一项更改,导致AngularFire2崩溃。 AngularFire2团队在5.1.3版中创建了修复程序。另外,您可以坚持使用Firebase JavaScript SDK的v5.10.1以避免冲突。

该问题已在AngularFire2存储库中进行了跟踪,因此请在此处查看最新信息:https://github.com/angular/angularfire2/issues/2059