Skip to content

Commit 6297299

Browse files
authored
feat(core): Upgrade to exp
1 parent a26676c commit 6297299

File tree

5 files changed

+164
-165
lines changed

5 files changed

+164
-165
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@angular/platform-browser": "^9.0.0 || ^10.0.0 || ^11.0.0",
5050
"@angular/platform-browser-dynamic": "^9.0.0 || ^10.0.0 || ^11.0.0",
5151
"@angular/router": "^9.0.0 || ^10.0.0 || ^11.0.0",
52-
"firebase": "^7.0 || ^8.0",
52+
"firebase": "^0.900.15",
5353
"firebase-admin": "^8.10.0",
5454
"firebase-functions": "^3.6.0",
5555
"firebase-tools": "^8.0.0",

src/core/angularfire2.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { AngularFireModule, FirebaseApp, ɵAngularFireSchedulers, ɵkeepUnstable
44
import { Observable, of, Subject } from 'rxjs';
55
import { COMMON_CONFIG } from '../test-config';
66
import { BrowserModule } from '@angular/platform-browser';
7-
import firebase from 'firebase/app';
7+
import { Reference } from 'firebase/database';
88
import { tap } from 'rxjs/operators';
99
import { TestScheduler } from 'rxjs/testing';
1010
import { rando } from '../firestore/utils.spec';
1111

1212
describe('angularfire', () => {
1313
let app: FirebaseApp;
14-
let rootRef: firebase.database.Reference;
15-
let questionsRef: firebase.database.Reference;
16-
let listOfQuestionsRef: firebase.database.Reference;
14+
let rootRef: Reference;
15+
let questionsRef: Reference;
16+
let listOfQuestionsRef: Reference;
1717
let defaultPlatform: PlatformRef;
1818
let appName: string;
1919

src/core/firebase.app.module.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import {
22
Inject, InjectionToken, isDevMode, ModuleWithProviders, NgModule, NgZone, Optional, PLATFORM_ID, VERSION as NG_VERSION, Version
33
} from '@angular/core';
4-
import firebase from 'firebase/app';
4+
import { FirebaseApp as FirebaseAppType, getApps, initializeApp, registerVersion } from 'firebase/app';
5+
import { Analytics } from 'firebase/analytics';
6+
import { Database } from 'firebase/database';
7+
import { Auth } from 'firebase/auth';
8+
import { FirebaseMessaging } from 'firebase/messaging';
9+
import { FirebasePerformance } from 'firebase/performance';
10+
import { StorageService } from 'firebase/storage';
11+
import { FirebaseFirestore } from 'firebase/firestore';
12+
import { Functions } from 'firebase/functions';
13+
import { RemoteConfig } from 'firebase/remote-config';
514

615
// INVESTIGATE Public types don't expose FirebaseOptions or FirebaseAppConfig, is this the case anylonger?
716
export interface FirebaseOptions {
@@ -17,19 +26,19 @@ export const FIREBASE_APP_NAME = new InjectionToken<string | FirebaseAppConfig |
1726

1827
// Have to implement as we need to return a class from the provider, we should consider exporting
1928
// this in the firebase/app types as this is our highest risk of breaks
20-
export class FirebaseApp implements Partial<firebase.app.App> {
29+
export class FirebaseApp implements Partial<FirebaseAppType> {
2130
name: string;
2231
options: {};
23-
analytics: () => firebase.analytics.Analytics;
24-
auth: () => firebase.auth.Auth;
25-
database: (databaseURL?: string) => firebase.database.Database;
26-
messaging: () => firebase.messaging.Messaging;
27-
performance: () => firebase.performance.Performance;
28-
storage: (storageBucket?: string) => firebase.storage.Storage;
32+
analytics: () => Analytics;
33+
auth: () => Auth;
34+
database: (databaseURL?: string) => Database;
35+
messaging: () => FirebaseMessaging;
36+
performance: () => FirebasePerformance;
37+
storage: (storageBucket?: string) => StorageService;
2938
delete: () => Promise<void>;
30-
firestore: () => firebase.firestore.Firestore;
31-
functions: (region?: string) => firebase.functions.Functions;
32-
remoteConfig: () => firebase.remoteConfig.RemoteConfig;
39+
firestore: () => FirebaseFirestore;
40+
functions: (region?: string) => Functions;
41+
remoteConfig: () => RemoteConfig;
3342
}
3443

3544
export const VERSION = new Version('ANGULARFIRE2_VERSION');
@@ -39,10 +48,10 @@ export function ɵfirebaseAppFactory(options: FirebaseOptions, zone: NgZone, nam
3948
const config = typeof nameOrConfig === 'object' && nameOrConfig || {};
4049
config.name = config.name || name;
4150
// Added any due to some inconsistency between @firebase/app and firebase types
42-
const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0] as any;
51+
const existingApp = getApps().filter(app => app && app.name === config.name)[0] as any;
4352
// We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
4453
// Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206
45-
const app = (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any))) as FirebaseApp;
54+
const app = (existingApp || zone.runOutsideAngular(() => initializeApp(options, config as any))) as FirebaseApp;
4655
try {
4756
if (JSON.stringify(options) !== JSON.stringify(app.options)) {
4857
const hmr = !!(module as any).hot;
@@ -115,7 +124,7 @@ export class AngularFireModule {
115124

116125
// tslint:disable-next-line:ban-types
117126
constructor(@Inject(PLATFORM_ID) platformId: Object) {
118-
firebase.registerVersion('angularfire', VERSION.full, platformId.toString());
119-
firebase.registerVersion('angular', NG_VERSION.full);
127+
registerVersion('angularfire', VERSION.full, platformId.toString());
128+
registerVersion('angular', NG_VERSION.full);
120129
}
121130
}

tslint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"curly": true,
1919
"directive-class-suffix": true,
2020
"no-shadowed-variable": false,
21+
"no-trailing-whitespace": {
22+
"severity": "warn"
23+
},
2124
"directive-selector": [
2225
true,
2326
"attribute",

0 commit comments

Comments
 (0)