[types] Get flow type working again; Fix majority of firestore type issues

This commit is contained in:
Chris Bianca
2017-11-17 11:07:52 +00:00
parent 5c43c88f6a
commit 8bd9684644
24 changed files with 2743 additions and 953 deletions

View File

@@ -6,9 +6,10 @@ import { NativeModules } from 'react-native';
import Log from '../utils/log';
import INTERNALS from './../internals';
import FirebaseCore from './../firebase';
import FirebaseApp from '../firebase-app';
import { nativeWithApp } from './../utils';
import type FirebaseApp from '../firebase-app';
const logs = {};
// Firebase Native SDKs that support multiple app instances
@@ -50,7 +51,7 @@ export default class ModuleBase {
_options: Object;
_appName: string;
_namespace: string;
_firebaseApp: Object;
_firebaseApp: FirebaseApp;
_eventEmitter: Object;
static _NAMESPACE: string;
static _NATIVE_MODULE: string;
@@ -61,7 +62,7 @@ export default class ModuleBase {
* @param options
* @param withEventEmitter
*/
constructor(firebaseApp: Object, options: Object, withEventEmitter: boolean = false) {
constructor(firebaseApp: FirebaseApp, options: Object, withEventEmitter: boolean = false) {
this._module = this.constructor._NATIVE_MODULE.replace('RNFirebase', '');
this._firebaseApp = firebaseApp;
this._appName = firebaseApp._name;
@@ -73,12 +74,7 @@ export default class ModuleBase {
const nativeModule = NativeModules[this.constructor._NATIVE_MODULE];
if (!nativeModule) {
throw new Error(
INTERNALS.STRINGS.ERROR_MISSING_MODULE(
this.constructor._NAMESPACE,
this.constructor._NATIVE_MODULE,
),
);
throw new Error(INTERNALS.STRINGS.ERROR_MISSING_MODULE(this.constructor._NAMESPACE, this.constructor._NATIVE_MODULE));
}
// used by the modules that extend ModuleBase
@@ -100,7 +96,7 @@ export default class ModuleBase {
* @param moduleName
* @private
*/
_setupEventEmitter(nativeModule, moduleName) {
_setupEventEmitter(nativeModule: Object, moduleName: string) {
this._eventEmitter = FirebaseCore._getOrSetNativeEmitter(`${this._appName}-${this._module}`, nativeModule);
const events = NATIVE_MODULE_EVENTS[moduleName];
@@ -117,7 +113,7 @@ export default class ModuleBase {
* @return {string}
* @private
*/
_getAppEventName(eventName) {
_getAppEventName(eventName: string) {
return `${this._appName}-${eventName}`;
}
@@ -131,9 +127,7 @@ export default class ModuleBase {
get log(): Log {
if (logs[this._namespace]) return logs[this._namespace];
return logs[this._namespace] = Log.createLogger(
`🔥 ${this._namespace.toUpperCase()}`,
);
return logs[this._namespace] = Log.createLogger(`🔥 ${this._namespace.toUpperCase()}`);
}
/*