Skip to content

Commit 5955925

Browse files
committed
Fixing the types to handle older Firebase SDKs
1 parent 1e39052 commit 5955925

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/analytics/analytics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export class AngularFireAnalytics {
3535
// @ts-ignore zapping in the UMD in the build script
3636
switchMap(() => zone.runOutsideAngular(() => import('firebase/analytics'))),
3737
map(() => _firebaseAppFactory(options, zone, nameOrConfig)),
38-
map(app => app.analytics()),
38+
// SEMVER no need to cast once we drop older Firebase
39+
map(app => <analytics.Analytics>app.analytics()),
3940
tap(analytics => {
4041
if (analyticsCollectionEnabled === false) { analytics.setAnalyticsCollectionEnabled(false) }
4142
}),

src/core/firebase.app.module.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { InjectionToken, NgModule, Optional, NgZone } from '@angular/core';
2-
import { auth, database, firestore, functions, messaging, storage, analytics, remoteConfig } from 'firebase/app';
2+
import { auth, database, messaging, storage, firestore, functions } from 'firebase/app';
33
// @ts-ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
44
import firebase from 'firebase/app'; // once fixed can pull in as "default as firebase" above
55

@@ -15,12 +15,16 @@ export const FIREBASE_APP_NAME = FirebaseNameOrConfigToken;
1515

1616
export type FirebaseDatabase = database.Database;
1717
export type FirebaseAuth = auth.Auth;
18-
export type FirebaseAnalytics = analytics.Analytics;
18+
// SEMVER analytics.Analytics;
19+
export type FirebaseAnalytics = any;
1920
export type FirebaseMessaging = messaging.Messaging;
21+
// SEMVER performance.Performance
22+
export type FirebasePerformance = any;
2023
export type FirebaseStorage = storage.Storage;
2124
export type FirebaseFirestore = firestore.Firestore;
2225
export type FirebaseFunctions = functions.Functions;
23-
export type FirebaseRemoteConfig = remoteConfig.RemoteConfig;
26+
// SEMVER remoteConfig.RemoteConfig;
27+
export type FirebaseRemoteConfig = any;
2428

2529
// Have to implement as we need to return a class from the provider, we should consider exporting
2630
// this in the firebase/app types as this is our highest risk of breaks
@@ -31,7 +35,7 @@ export class FirebaseApp {
3135
auth: () => FirebaseAuth;
3236
database: (databaseURL?: string) => FirebaseDatabase;
3337
messaging: () => FirebaseMessaging;
34-
performance: () => any; // SEMVER: once >= 6 import performance.Performance
38+
performance: () => FirebasePerformance;
3539
storage: (storageBucket?: string) => FirebaseStorage;
3640
delete: () => Promise<void>;
3741
firestore: () => FirebaseFirestore;

src/remote-config/remote-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export class AngularFireRemoteConfig {
7575
// @ts-ignore zapping in the UMD in the build script
7676
switchMap(() => import('firebase/remote-config')),
7777
map(() => _firebaseAppFactory(options, zone, nameOrConfig)),
78-
map(app => app.remoteConfig()),
78+
// SEMVER no need to cast once we drop older Firebase
79+
map(app => <remoteConfig.RemoteConfig>app.remoteConfig()),
7980
tap(rc => {
8081
if (settings) { rc.settings = settings }
8182
if (defaultConfig) { rc.defaultConfig = defaultConfig }

0 commit comments

Comments
 (0)