根据官方文档导入@angular/fire in app.module 时输入错误?
Type error when importing @angular/fire in app.module based on the official documentation?
I'm using the official documentation here 尝试将 firebase 添加到我的 angular 应用程序,但我不断收到以下类型错误:
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)
这是一个专门为测试 firebase 而构建的新项目,在这里待了一段时间后,在 github 和 firebase slack 上,我似乎无法弄清楚我是什么基本东西做错了。
我的导入:
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';
在 app.module 的导入数组中:
AngularFireModule.initializeApp(config), // <== this one throws the error
AngularFirestoreModule, // firestore
AngularFireAuthModule, // auth
我使用了命令:
yarn add firebase @angular/fire
按照文档和我的 package.json 安装,我有:
"firebase": "^6.2.2",
"@angular/fire": "^5.2.1",
将 Angular 8 与这些版本一起使用:
"@angular/animations": "~8.0.2",
"@angular/common": "~8.0.2",
"@angular/compiler": "~8.0.2",
"@angular/core": "~8.0.2",
事实证明一切正常,我在错误的数组中导入它而没有注意到。
I'm using the official documentation here 尝试将 firebase 添加到我的 angular 应用程序,但我不断收到以下类型错误:
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)
这是一个专门为测试 firebase 而构建的新项目,在这里待了一段时间后,在 github 和 firebase slack 上,我似乎无法弄清楚我是什么基本东西做错了。
我的导入:
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireAuthModule } from '@angular/fire/auth';
在 app.module 的导入数组中:
AngularFireModule.initializeApp(config), // <== this one throws the error
AngularFirestoreModule, // firestore
AngularFireAuthModule, // auth
我使用了命令:
yarn add firebase @angular/fire
按照文档和我的 package.json 安装,我有:
"firebase": "^6.2.2",
"@angular/fire": "^5.2.1",
将 Angular 8 与这些版本一起使用:
"@angular/animations": "~8.0.2",
"@angular/common": "~8.0.2",
"@angular/compiler": "~8.0.2",
"@angular/core": "~8.0.2",
事实证明一切正常,我在错误的数组中导入它而没有注意到。