Search code examples
javascriptangularfirebaseionic-frameworkangularfire2

'performance' is missing in type 'FirebaseApp'


I'm trying to connect the firebase in my app, but I'm getting the same error, I've tried a lot of things, but none of them worked. First of all, I installed the firebase and the @angular/fire

npm install firebase @angular/fire --save

After that, I changed the environment.ts to

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

as the documentatio talked. (I put the XX,but in the real environment.ts o put ther correct one). Then, I changed the app.module.ts to

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 {}

and when I've run the code

ionic serve

I've got the error.

ERROR in node_modules/@angular/fire/firebase.app.module.d.ts(17,22): error TS2420: Class 'FirebaseApp' incorrectly implements interface 'App'. Property 'performance' is missing in type 'FirebaseApp'.

then I looked for firebase.app.module.d.ts then

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;
        }[];
    };
}

I don't know how I must fix it... I saw I little tips in the stackoverflow and other sites but none of them worked.

that is the documentation I've followed 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

Solution

  • firebaser here

    Update: This issue has been fixed in AngularFire2 release 5.1.3. Upgrade to this version to get rid of the problem.


    Version 5.11.0 Firebase SDK for JavaScript, introduced a change caused AngularFire2 to break. The AngularFire2 team created a fix in release 5.1.3. Alternatively you can stick to v5.10.1 of the Firebase JavaScript SDK to avoid the conflict.

    The issue is tracked on the AngularFire2 repo, so please check here for the latest information: https://github.com/angular/angularfire2/issues/2059.