angularfirebaseangularfire2angularfireangularfire5

Type error when importing @angular/fire in app.module based on the official documentation?


I'm using the official documentation here to try to add firebase to my angular app, but I keep getting the following type error:

ype '{ ngModule: typeof AngularFireModule; providers: { provide: InjectionToken<string | FirebaseAppConfig>; useValue: string | FirebaseAppConfig; }[]; }' is not assignable to type 'any[] | Type<any>'.
  Type '{ ngModule: typeof AngularFireModule; providers: { provide: InjectionToken<string | FirebaseAppConfig>; useValue: string | FirebaseAppConfig; }[]; }' is missing the following properties from type 'Type<any>': apply, call, bind, prototype, and 5 more.ts(2322)

this is a fresh project built specifically to test firebase out and after a bit of time here, on github and on the firebase slack, I can't seem to figure out what basic thing I'm doing wrong.

My imports:

import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';

in the imports array in app.module:

AngularFireModule.initializeApp(config), // <== this one throws the error
AngularFirestoreModule, // firestore
AngularFireAuthModule, // auth

I used the command:

yarn add firebase @angular/fire

to install as in the documentation and in my package.json I have:

    "firebase": "^6.2.2",
    "@angular/fire": "^5.2.1",

Using Angular 8 with these versions:

    "@angular/animations": "~8.0.2",
    "@angular/common": "~8.0.2",
    "@angular/compiler": "~8.0.2",
    "@angular/core": "~8.0.2",

Solution

  • Turns out everything works fine, I was importing it in the wrong array and didn't notice.