Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): lean only on firebase types and compatibility with 5.0.4 #1729

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a name="5.0.0-rc.11"></a>
# [5.0.0-rc.11](https://github.com/angular/angularfire2/compare/5.0.0-rc.10...5.0.0-rc.11) (2018-06-13)

### Bug Fixes

* Fixed SSR compilation and misc. typing issues ([#1729](https://github.com/angular/angularfire2/issues/1729)) ([eed5802](https://github.com/angular/angularfire2/commit/eed5802))


<a name="5.0.0-rc.10"></a>
# [5.0.0-rc.10](https://github.com/angular/angularfire2/compare/5.0.0-rc.9...5.0.0-rc.10) (2018-05-22)

Expand Down
2 changes: 1 addition & 1 deletion docs/auth/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the Firebase docs for more information on what methods are available.](https://f
```ts
import { Component } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import { auth } from 'firebase/app';
import { auth } from 'firebase';

@Component({
selector: 'app-root',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularfire2",
"version": "5.0.0-rc.10",
"version": "5.0.0-rc.11",
"description": "The official library of Firebase and Angular.",
"private": true,
"scripts": {
Expand Down Expand Up @@ -34,8 +34,8 @@
"@angular/core": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"firebase": "^5.0.3",
"bufferutil": "^3.0.3",
"firebase": "^5.0.3",
"rxjs": "^6.0.0",
"utf-8-validate": "^4.0.0",
"ws": "^3.3.2",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from 'firebase/app';
import { User } from 'firebase';
import { ReflectiveInjector, Provider } from '@angular/core';
import { Observable, Subject } from 'rxjs'
import { TestBed, inject } from '@angular/core/testing';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable, of, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions } from 'angularfire2';

import { User, auth } from 'firebase/app';
import { User, auth } from 'firebase';

import { FirebaseAuth, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';

Expand Down
2 changes: 1 addition & 1 deletion src/core/angularfire2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FirebaseApp, AngularFireModule } from 'angularfire2';
import { Subscription } from 'rxjs';
import { COMMON_CONFIG } from './test-config';
import { BrowserModule } from '@angular/platform-browser';
import { database } from 'firebase/app';
import { database } from 'firebase';

describe('angularfire', () => {
let subscription:Subscription;
Expand Down
7 changes: 4 additions & 3 deletions src/core/firebase.app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { InjectionToken, NgZone, NgModule, Optional } from '@angular/core';
import { app, auth, apps, database, firestore, functions, initializeApp, messaging, storage } from 'firebase/app';
import { app, auth, database, firestore, functions, messaging, storage } from 'firebase';
import * as firebase from 'firebase/app';

// Public types don't expose FirebaseOptions or FirebaseAppConfig
export type FirebaseOptions = {[key:string]: any};
Expand Down Expand Up @@ -34,9 +35,9 @@ export function _firebaseAppFactory(options: FirebaseOptions, nameOrConfig?: str
const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]';
const config = typeof nameOrConfig === 'object' && nameOrConfig || {};
config.name = config.name || name;
const existingApp = apps.filter(app => app && app.name === config.name)[0];
const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0];
// We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
return (existingApp || (initializeApp as any)(options, config)) as FirebaseApp;
return (existingApp || firebase.initializeApp(options, <any>config)) as FirebaseApp;
}

const FirebaseAppProvider = {
Expand Down
4 changes: 2 additions & 2 deletions src/database-deprecated/firebase_list_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function firebaseListObservable(ref: Reference | DatabaseQuery, {preserveSnapsho
snap.forEach((child: any) => {
lastLoadedKey = child.key;
});
if (array.find((child: any) => toKey(child) === lastLoadedKey)) {
if ((<any>array).find((child: any) => toKey(child) === lastLoadedKey)) {
hasLoaded = true;
obs.next(array);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ function firebaseListObservable(ref: Reference | DatabaseQuery, {preserveSnapsho
// The Firebase SDK requires the reference, event name, and callback to
// properly unsubscribe, otherwise it can affect other subscriptions.
handles.forEach(item => {
ref.off(item.event, item.handle);
ref.off(item.event as any, item.handle);
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/firebase_object_observable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
import { Reference } from './interfaces';
import { database } from 'firebase/app';
import { database } from 'firebase';

export class FirebaseObjectObservable<T> extends Observable<T> {
constructor(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void, public $ref?:Reference) {
Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { database } from 'firebase/app';
import { database } from 'firebase';

export type Reference = database.Reference;
export type DataSnapshot = database.DataSnapshot;
Expand Down
2 changes: 1 addition & 1 deletion src/database/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { database } from 'firebase/app';
import { database } from 'firebase';

export type FirebaseOperation = string | database.Reference | database.DataSnapshot;

Expand Down
4 changes: 2 additions & 2 deletions src/database/list/changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reference } from 'firebase/database-types';
import { database } from 'firebase';
import { FirebaseApp, AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, listChanges } from 'angularfire2/database';
import { TestBed, inject } from '@angular/core/testing';
Expand All @@ -12,7 +12,7 @@ const FIREBASE_APP_NAME = rando();
describe('listChanges', () => {
let app: FirebaseApp;
let db: AngularFireDatabase;
let ref: (path: string) => Reference;
let ref: (path: string) => database.Reference;
let batch = {};
const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ( { key: i.toString(), ...item } ));
Object.keys(items).forEach(function (key, i) {
Expand Down
3 changes: 1 addition & 2 deletions src/database/list/remove.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DatabaseReference, DataSnapshot, FirebaseOperation, DatabaseSnapshot } from '../interfaces';
import { checkOperationCases } from '../utils';
import { createDataOperationMethod } from './data-operation';
import { database } from 'firebase/app';
import { database } from 'firebase';

// TODO(davideast): Find out why TS thinks this returns firebase.Primise
// instead of Promise.
Expand Down
4 changes: 2 additions & 2 deletions src/database/list/snapshot-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reference } from 'firebase/database-types';
import { database } from 'firebase';
import { FirebaseApp, AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, snapshotChanges, ChildEvent } from 'angularfire2/database';
import { TestBed, inject } from '@angular/core/testing';
Expand All @@ -13,7 +13,7 @@ const FIREBASE_APP_NAME = rando();
describe('snapshotChanges', () => {
let app: FirebaseApp;
let db: AngularFireDatabase;
let createRef: (path: string) => Reference;
let createRef: (path: string) => database.Reference;
let batch = {};
const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ( { key: i.toString(), ...item } ));
Object.keys(items).forEach(function (key, i) {
Expand Down
4 changes: 2 additions & 2 deletions src/database/list/state-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reference } from 'firebase/database-types';
import { database } from 'firebase';
import { FirebaseApp, AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, AngularFireDatabaseModule, stateChanges, ChildEvent } from 'angularfire2/database';
import { TestBed, inject } from '@angular/core/testing';
Expand All @@ -12,7 +12,7 @@ const FIREBASE_APP_NAME = rando();
describe('stateChanges', () => {
let app: FirebaseApp;
let db: AngularFireDatabase;
let createRef: (path: string) => Reference;
let createRef: (path: string) => database.Reference;
let batch = {};
const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ( { key: i.toString(), ...item } ));
Object.keys(items).forEach(function (key, i) {
Expand Down
6 changes: 3 additions & 3 deletions src/firestore/firestore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';

import { Observable, Subscriber, of, from } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { firestore } from 'firebase/app';
import { Observable, of, from } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { firestore } from 'firebase';

import { Settings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
import { AngularFirestoreDocument } from './document/document';
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Subscriber } from 'rxjs';
import { firestore } from 'firebase/app';
import { firestore } from 'firebase';

export type Settings = firestore.Settings;
export type CollectionReference = firestore.CollectionReference;
Expand Down
4 changes: 2 additions & 2 deletions src/firestore/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FirebaseFirestore, CollectionReference } from 'firebase/firestore-types';
import { firestore } from 'firebase';
import { AngularFirestoreCollection } from './collection/collection';

export interface Stock {
Expand All @@ -10,7 +10,7 @@ export const FAKE_STOCK_DATA = { name: 'FAKE', price: 1 };

export const randomName = (firestore): string => firestore.collection('a').doc().id;

export const createRandomStocks = async (firestore: FirebaseFirestore, collectionRef: CollectionReference, numberOfItems) => {
export const createRandomStocks = async (firestore: firestore.Firestore, collectionRef: firestore.CollectionReference, numberOfItems) => {
// Create a batch to update everything at once
const batch = firestore.batch();
// Store the random names to delete them later
Expand Down
2 changes: 1 addition & 1 deletion src/storage/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { storage } from 'firebase/app';
import { storage } from 'firebase';

export type UploadTask = storage.UploadTask;
export type UploadTaskSnapshot = storage.UploadTaskSnapshot;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/observable/fromTask.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable } from 'rxjs';
import { UploadTask, UploadTaskSnapshot } from '../interfaces';
import { storage } from 'firebase/app';
import { storage } from 'firebase';

export function fromTask(task: UploadTask) {
return new Observable<UploadTaskSnapshot>(subscriber => {
Expand Down
Loading