mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 17:42:24 +08:00
[types] -
This commit is contained in:
248
packages/app-types/index.d.ts
vendored
248
packages/app-types/index.d.ts
vendored
@@ -15,252 +15,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
export interface NativeFirebaseError extends Error {
|
||||
/**
|
||||
* Firebase error code, e.g. `auth/invalid-email`
|
||||
*/
|
||||
readonly code: string;
|
||||
|
||||
/**
|
||||
* Firebase error message
|
||||
*/
|
||||
readonly message: string;
|
||||
|
||||
/**
|
||||
* The firebase module namespace that this error originated from, e.g. 'analytics'
|
||||
*/
|
||||
readonly namespace: string;
|
||||
|
||||
/**
|
||||
* The native sdks returned error code, different per platform
|
||||
*/
|
||||
readonly nativeErrorCode: string | number;
|
||||
|
||||
/**
|
||||
* The native sdks returned error message, different per platform
|
||||
*/
|
||||
readonly nativeErrorMessage: string;
|
||||
}
|
||||
|
||||
export type FirebaseOptions = {
|
||||
/**
|
||||
* The Google App ID that is used to uniquely identify an instance of an app.
|
||||
*/
|
||||
appId: string;
|
||||
|
||||
/**
|
||||
* An API key used for authenticating requests from your app, e.g.
|
||||
* "AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers.
|
||||
*/
|
||||
apiKey?: string;
|
||||
|
||||
/**
|
||||
* The database root URL, e.g. "http://abc-xyz-123.firebaseio.com".
|
||||
*/
|
||||
databaseURL?: string;
|
||||
|
||||
/**
|
||||
* The Project ID from the Firebase console, for example "abc-xyz-123".
|
||||
*/
|
||||
projectId: string;
|
||||
|
||||
/**
|
||||
* The tracking ID for Google Analytics, e.g. "UA-12345678-1", used to configure Google Analytics.
|
||||
*/
|
||||
gaTrackingId?: string;
|
||||
|
||||
/**
|
||||
* The Google Cloud Storage bucket name, e.g. "abc-xyz-123.storage.firebase.com".
|
||||
*/
|
||||
storageBucket?: string;
|
||||
|
||||
/**
|
||||
* The Project Number from the Google Developer's console, for example "012345678901", used to
|
||||
* configure Google Cloud Messaging.
|
||||
*/
|
||||
messagingSenderId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The OAuth2 client ID for iOS application used to authenticate Google users, for example
|
||||
* "12345.apps.googleusercontent.com", used for signing in with Google.
|
||||
*/
|
||||
clientId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The Android client ID used in Google AppInvite when an iOS app has its Android version, for
|
||||
* example "12345.apps.googleusercontent.com".
|
||||
*/
|
||||
androidClientId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The URL scheme used to set up Durable Deep Link service.
|
||||
*/
|
||||
deepLinkURLScheme?: string;
|
||||
[name: string]: any;
|
||||
};
|
||||
|
||||
export interface FirebaseAppConfig {
|
||||
/**
|
||||
* The Firebase App name, defaults to [DEFAULT] if none provided.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
automaticDataCollectionEnabled?: boolean;
|
||||
|
||||
/**
|
||||
* If set to true it indicates that Firebase should close database connections
|
||||
* automatically when the app is in the background. Disabled by default.
|
||||
*/
|
||||
automaticResourceManagement?: boolean;
|
||||
}
|
||||
|
||||
export interface FirebaseApp {
|
||||
/**
|
||||
* The name (identifier) for this App. '[DEFAULT]' is the default App.
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* The (read-only) configuration options from the app initialization.
|
||||
*/
|
||||
readonly options: FirebaseOptions;
|
||||
|
||||
/**
|
||||
* Make this app unusable and free up resources.
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface FirebaseJSON {
|
||||
|
||||
}
|
||||
|
||||
export interface ReactNativeFirebaseNamespace {
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param config The optional config for your firebase app
|
||||
*/
|
||||
initializeApp(options: FirebaseOptions, config?: FirebaseAppConfig): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param name The optional name of the app to initialize ('[DEFAULT]' if
|
||||
* omitted)
|
||||
*/
|
||||
initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Retrieve an instance of a FirebaseApp.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const app = firebase.app('foo');
|
||||
* ```
|
||||
*
|
||||
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
|
||||
*/
|
||||
app(name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* A (read-only) array of all the initialized Apps.
|
||||
*/
|
||||
apps: FirebaseApp[];
|
||||
|
||||
/**
|
||||
* The current React Native Firebase version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
}
|
||||
|
||||
export class ReactNativeFirebaseModule {
|
||||
app: FirebaseApp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @firebase app
|
||||
*/
|
||||
export namespace App {
|
||||
export interface FirebaseApp {
|
||||
/**
|
||||
* The name (identifier) for this App. '[DEFAULT]' is the default App.
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* The (read-only) configuration options from the app initialization.
|
||||
*/
|
||||
readonly options: FirebaseOptions;
|
||||
|
||||
/**
|
||||
* Make this app unusable and free up resources.
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ReactNativeFirebaseNamespace {
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param config The optional config for your firebase app
|
||||
*/
|
||||
initializeApp(options: FirebaseOptions, config?: FirebaseAppConfig): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param name The optional name of the app to initialize ('[DEFAULT]' if
|
||||
* omitted)
|
||||
*/
|
||||
initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Retrieve an instance of a FirebaseApp.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const app = firebase.app('foo');
|
||||
* ```
|
||||
*
|
||||
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
|
||||
*/
|
||||
app(name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* A (read-only) array of all the initialized Apps.
|
||||
*/
|
||||
apps: FirebaseApp[];
|
||||
|
||||
/**
|
||||
* The current React Native Firebase version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
}
|
||||
}
|
||||
|
||||
export type ReactNativeFirebaseModuleAndStatics<M, S = {}> = {
|
||||
(): M;
|
||||
|
||||
/**
|
||||
* This React Native Firebase module version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
} & S;
|
||||
|
||||
export type ReactNativeFirebaseModuleAndStaticsWithApp<M, S = {}> = {
|
||||
(app?: FirebaseApp): M;
|
||||
|
||||
/**
|
||||
* This React Native Firebase module version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
} & S;
|
||||
|
||||
207
packages/app/lib/index.d.ts
vendored
207
packages/app/lib/index.d.ts
vendored
@@ -15,27 +15,194 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import { ReactNativeFirebaseNamespace } from '@react-native-firebase/app-types';
|
||||
|
||||
/**
|
||||
* @firebase firebase
|
||||
* @firebase app
|
||||
*/
|
||||
export namespace ReactNativeFirebase {
|
||||
export interface NativeFirebaseError extends Error {
|
||||
/**
|
||||
* Firebase error code, e.g. `auth/invalid-email`
|
||||
*/
|
||||
readonly code: string;
|
||||
|
||||
/**
|
||||
* Firebase error message
|
||||
*/
|
||||
readonly message: string;
|
||||
|
||||
/**
|
||||
* The firebase module namespace that this error originated from, e.g. 'analytics'
|
||||
*/
|
||||
readonly namespace: string;
|
||||
|
||||
/**
|
||||
* The native sdks returned error code, different per platform
|
||||
*/
|
||||
readonly nativeErrorCode: string | number;
|
||||
|
||||
/**
|
||||
* The native sdks returned error message, different per platform
|
||||
*/
|
||||
readonly nativeErrorMessage: string;
|
||||
}
|
||||
|
||||
export type FirebaseAppOptions = {
|
||||
/**
|
||||
* The Google App ID that is used to uniquely identify an instance of an app.
|
||||
*/
|
||||
appId: string;
|
||||
|
||||
/**
|
||||
* An API key used for authenticating requests from your app, e.g.
|
||||
* "AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers.
|
||||
*/
|
||||
apiKey?: string;
|
||||
|
||||
/**
|
||||
* The database root URL, e.g. "http://abc-xyz-123.firebaseio.com".
|
||||
*/
|
||||
databaseURL?: string;
|
||||
|
||||
/**
|
||||
* The Project ID from the Firebase console, for example "abc-xyz-123".
|
||||
*/
|
||||
projectId: string;
|
||||
|
||||
/**
|
||||
* The tracking ID for Google Analytics, e.g. "UA-12345678-1", used to configure Google Analytics.
|
||||
*/
|
||||
gaTrackingId?: string;
|
||||
|
||||
/**
|
||||
* The Google Cloud Storage bucket name, e.g. "abc-xyz-123.storage.firebase.com".
|
||||
*/
|
||||
storageBucket?: string;
|
||||
|
||||
/**
|
||||
* The Project Number from the Google Developer's console, for example "012345678901", used to
|
||||
* configure Google Cloud Messaging.
|
||||
*/
|
||||
messagingSenderId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The OAuth2 client ID for iOS application used to authenticate Google users, for example
|
||||
* "12345.apps.googleusercontent.com", used for signing in with Google.
|
||||
*/
|
||||
clientId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The Android client ID used in Google AppInvite when an iOS app has its Android version, for
|
||||
* example "12345.apps.googleusercontent.com".
|
||||
*/
|
||||
androidClientId?: string;
|
||||
|
||||
/**
|
||||
* iOS only - The URL scheme used to set up Durable Deep Link service.
|
||||
*/
|
||||
deepLinkURLScheme?: string;
|
||||
[name: string]: any;
|
||||
};
|
||||
|
||||
export interface FirebaseAppConfig {
|
||||
/**
|
||||
* The Firebase App name, defaults to [DEFAULT] if none provided.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
automaticDataCollectionEnabled?: boolean;
|
||||
|
||||
/**
|
||||
* If set to true it indicates that Firebase should close database connections
|
||||
* automatically when the app is in the background. Disabled by default.
|
||||
*/
|
||||
automaticResourceManagement?: boolean;
|
||||
}
|
||||
|
||||
export interface FirebaseApp {
|
||||
/**
|
||||
* The name (identifier) for this App. '[DEFAULT]' is the default App.
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* The (read-only) configuration options from the app initialization.
|
||||
*/
|
||||
readonly options: FirebaseAppOptions;
|
||||
|
||||
/**
|
||||
* Make this app unusable and free up resources.
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Module {
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param config The optional config for your firebase app
|
||||
*/
|
||||
initializeApp(options: FirebaseAppOptions, config?: FirebaseAppConfig): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Create (and initialize) a FirebaseApp.
|
||||
*
|
||||
* @param options Options to configure the services used in the App.
|
||||
* @param name The optional name of the app to initialize ('[DEFAULT]' if
|
||||
* omitted)
|
||||
*/
|
||||
initializeApp(options: FirebaseAppOptions, name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* Retrieve an instance of a FirebaseApp.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const app = firebase.app('foo');
|
||||
* ```
|
||||
*
|
||||
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
|
||||
*/
|
||||
app(name?: string): FirebaseApp;
|
||||
|
||||
/**
|
||||
* A (read-only) array of all the initialized Apps.
|
||||
*/
|
||||
apps: FirebaseApp[];
|
||||
|
||||
/**
|
||||
* The current React Native Firebase version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
}
|
||||
|
||||
export class FirebaseModule {
|
||||
app: FirebaseApp;
|
||||
}
|
||||
|
||||
export type FirebaseModuleWithStatics<M, S = {}> = {
|
||||
(): M;
|
||||
|
||||
/**
|
||||
* This React Native Firebase module version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
} & S;
|
||||
|
||||
export type FirebaseModuleWithStaticsAndApp<M, S = {}> = {
|
||||
(app?: FirebaseApp): M;
|
||||
|
||||
/**
|
||||
* This React Native Firebase module version.
|
||||
*/
|
||||
readonly SDK_VERSION: string;
|
||||
} & S;
|
||||
}
|
||||
|
||||
declare module '@react-native-firebase/app' {
|
||||
import { ReactNativeFirebaseNamespace, FirebaseJSON } from '@react-native-firebase/app-types';
|
||||
const ReactNativeFirebase: {} & ReactNativeFirebaseNamespace;
|
||||
export default ReactNativeFirebase;
|
||||
const FirebaseJSON: {} & FirebaseJSON;
|
||||
export const FirebaseJSON;
|
||||
}
|
||||
|
||||
declare module '@react-native-firebase/app-types' {
|
||||
interface ReactNativeFirebaseNamespace {
|
||||
utils?: {
|
||||
(app?: FirebaseApp): FirebaseUtilsModule;
|
||||
};
|
||||
}
|
||||
|
||||
interface FirebaseApp {
|
||||
utils?(app?: FirebaseApp): FirebaseUtilsModule;
|
||||
}
|
||||
const module: {} & ReactNativeFirebase.Module;
|
||||
export default module;
|
||||
}
|
||||
|
||||
17
packages/perf/type-test.ts
Normal file
17
packages/perf/type-test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import firebase from '@react-native-firebase/app';
|
||||
import { firebase as firebaseFromModule } from '@react-native-firebase/perf';
|
||||
|
||||
// checks module exists at root
|
||||
console.log(firebase.perf().app.name);
|
||||
|
||||
// checks module exists at app level
|
||||
console.log(firebase.app().perf().app.name);
|
||||
|
||||
// checks statics exist
|
||||
console.log(firebase.perf.SDK_VERSION);
|
||||
|
||||
// checks root exists
|
||||
console.log(firebase.SDK_VERSION);
|
||||
|
||||
// checks firebase named export exists on module
|
||||
console.log(firebaseFromModule.SDK_VERSION);
|
||||
41
packages/storage/lib/index.d.ts
vendored
41
packages/storage/lib/index.d.ts
vendored
@@ -15,12 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import {
|
||||
NativeFirebaseError,
|
||||
ReactNativeFirebaseModule,
|
||||
ReactNativeFirebaseModuleAndStatics,
|
||||
ReactNativeFirebaseNamespace,
|
||||
} from '@react-native-firebase/app-types';
|
||||
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
||||
|
||||
/**
|
||||
* Firebase Cloud Storage package for React Native.
|
||||
@@ -59,6 +54,9 @@ import {
|
||||
* @firebase storage
|
||||
*/
|
||||
export namespace Storage {
|
||||
import FirebaseModule = ReactNativeFirebase.FirebaseModule;
|
||||
import NativeFirebaseError = ReactNativeFirebase.NativeFirebaseError;
|
||||
|
||||
/**
|
||||
* Possible string formats used for uploading via `StorageReference.putString()`
|
||||
*
|
||||
@@ -1026,7 +1024,7 @@ export namespace Storage {
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
export class Module extends ReactNativeFirebaseModule {
|
||||
export class Module extends FirebaseModule {
|
||||
/**
|
||||
* Returns the maximum time to retry an upload if a failure occurs.
|
||||
*
|
||||
@@ -1130,26 +1128,27 @@ export namespace Storage {
|
||||
}
|
||||
|
||||
declare module '@react-native-firebase/storage' {
|
||||
import { ReactNativeFirebaseNamespace } from '@react-native-firebase/app-types';
|
||||
import ReactNativeFirebaseModule = ReactNativeFirebase.Module;
|
||||
import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics;
|
||||
|
||||
const FirebaseNamespaceExport: {} & ReactNativeFirebaseNamespace;
|
||||
const firebaseNamedExport: {} & ReactNativeFirebaseModule;
|
||||
export const firebase = firebaseNamedExport;
|
||||
|
||||
export const firebase = FirebaseNamespaceExport;
|
||||
|
||||
const StorageDefaultExport: ReactNativeFirebaseModuleAndStatics<Storage.Module, Storage.Statics>;
|
||||
|
||||
export default StorageDefaultExport;
|
||||
const module: FirebaseModuleWithStatics<Storage.Module, Storage.Statics>;
|
||||
export default module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach namespace to `firebase.` and `FirebaseApp.`.
|
||||
*/
|
||||
declare module '@react-native-firebase/app-types' {
|
||||
interface ReactNativeFirebaseNamespace {
|
||||
storage: ReactNativeFirebaseModuleAndStatics<Storage.Module, Storage.Statics>;
|
||||
}
|
||||
|
||||
interface FirebaseApp {
|
||||
storage?(bucket?: string): Storage.Module;
|
||||
declare module '@react-native-firebase/app' {
|
||||
namespace ReactNativeFirebase {
|
||||
import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics;
|
||||
interface Module {
|
||||
storage: FirebaseModuleWithStatics<Storage.Module, Storage.Statics>;
|
||||
}
|
||||
interface FirebaseApp {
|
||||
storage(bucket?: string): Storage.Module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
packages/storage/type-test.ts
Normal file
17
packages/storage/type-test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import firebase from '@react-native-firebase/app';
|
||||
import { firebase as firebaseFromModule } from '@react-native-firebase/storage';
|
||||
|
||||
// checks module exists at root
|
||||
console.log(firebase.storage().app.name);
|
||||
|
||||
// checks module exists at app level
|
||||
console.log(firebase.app().storage().app.name);
|
||||
|
||||
// checks statics exist
|
||||
console.log(firebase.storage.SDK_VERSION);
|
||||
|
||||
// checks root exists
|
||||
console.log(firebase.SDK_VERSION);
|
||||
|
||||
// checks firebase named export exists on module
|
||||
console.log(firebaseFromModule.SDK_VERSION);
|
||||
@@ -63,3 +63,4 @@ android/.settings
|
||||
*.coverage.json
|
||||
.circleci
|
||||
.eslintignore
|
||||
type-test.ts
|
||||
|
||||
65
packages/utils/lib/index.d.ts
vendored
65
packages/utils/lib/index.d.ts
vendored
@@ -15,11 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import {
|
||||
ReactNativeFirebaseModule,
|
||||
ReactNativeFirebaseNamespace,
|
||||
ReactNativeFirebaseModuleAndStatics,
|
||||
} from '@react-native-firebase/app-types';
|
||||
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
||||
|
||||
/**
|
||||
* React Native Firebase Utilities package.
|
||||
@@ -58,6 +54,8 @@ import {
|
||||
* @firebase utils
|
||||
*/
|
||||
export namespace Utils {
|
||||
import FirebaseModule = ReactNativeFirebase.FirebaseModule;
|
||||
|
||||
export interface Statics {}
|
||||
|
||||
/**
|
||||
@@ -73,7 +71,7 @@ export namespace Utils {
|
||||
* const defaultAppUtils = firebase.utils();
|
||||
* ```
|
||||
*/
|
||||
export class Module extends ReactNativeFirebaseModule {
|
||||
export class Module extends FirebaseModule {
|
||||
/**
|
||||
* Returns true if this app is running inside a Firebase Test Lab environment. Always returns false on iOS.
|
||||
*
|
||||
@@ -84,47 +82,34 @@ export namespace Utils {
|
||||
}
|
||||
|
||||
declare module '@react-native-firebase/utils' {
|
||||
import { ReactNativeFirebaseNamespace } from '@react-native-firebase/app-types';
|
||||
import ReactNativeFirebaseModule = ReactNativeFirebase.Module;
|
||||
import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics;
|
||||
|
||||
const FirebaseNamespaceExport: {} & ReactNativeFirebaseNamespace;
|
||||
const firebaseNamedExport: {} & ReactNativeFirebaseModule;
|
||||
export const firebase = firebaseNamedExport;
|
||||
|
||||
/**
|
||||
* @example
|
||||
* ```js
|
||||
* import { firebase } from '@react-native-firebase/utils';
|
||||
* firebase.utils().X(...);
|
||||
* ```
|
||||
*/
|
||||
export const firebase = FirebaseNamespaceExport;
|
||||
|
||||
const UtilsDefaultExport: ReactNativeFirebaseModuleAndStatics<Utils.Module, Utils.Statics>;
|
||||
/**
|
||||
* @example
|
||||
* ```js
|
||||
* import utils from '@react-native-firebase/utils';
|
||||
* utils().X(...);
|
||||
* ```
|
||||
*/
|
||||
export default UtilsDefaultExport;
|
||||
const module: FirebaseModuleWithStatics<Utils.Module, Utils.Statics>;
|
||||
export default module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach namespace to `firebase.` and `FirebaseApp.`.
|
||||
*/
|
||||
declare module '@react-native-firebase/app-types' {
|
||||
interface ReactNativeFirebaseNamespace {
|
||||
/**
|
||||
* Utils provides a collection of utilities to aid in using Firebase
|
||||
* and related services inside React Native, e.g. Test Lab helpers
|
||||
* and Google Play Services version helpers.
|
||||
*/
|
||||
utils: ReactNativeFirebaseModuleAndStatics<Utils.Module, Utils.Statics>;
|
||||
}
|
||||
declare module '@react-native-firebase/app' {
|
||||
namespace ReactNativeFirebase {
|
||||
import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics;
|
||||
|
||||
interface FirebaseApp {
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
utils(): Utils.Module;
|
||||
interface Module {
|
||||
/**
|
||||
* Utils provides a collection of utilities to aid in using Firebase
|
||||
* and related services inside React Native, e.g. Test Lab helpers
|
||||
* and Google Play Services version helpers.
|
||||
*/
|
||||
utils: FirebaseModuleWithStatics<Utils.Module, Utils.Statics>;
|
||||
}
|
||||
|
||||
interface FirebaseApp {
|
||||
utils(): Utils.Module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
packages/utils/type-test.ts
Normal file
17
packages/utils/type-test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import firebase from '@react-native-firebase/app';
|
||||
import { firebase as firebaseFromModule } from '@react-native-firebase/utils';
|
||||
|
||||
// checks module exists at root
|
||||
console.log(firebase.utils().app.name);
|
||||
|
||||
// checks module exists at app level
|
||||
console.log(firebase.app().utils().app.name);
|
||||
|
||||
// checks statics exist
|
||||
console.log(firebase.utils.SDK_VERSION);
|
||||
|
||||
// checks root exists
|
||||
console.log(firebase.SDK_VERSION);
|
||||
|
||||
// checks firebase named export exists on module
|
||||
console.log(firebaseFromModule.SDK_VERSION);
|
||||
@@ -1,39 +0,0 @@
|
||||
import '@react-native-firebase/storage';
|
||||
import '@react-native-firebase/perf';
|
||||
import '@react-native-firebase/functions';
|
||||
|
||||
import { VisionCloudTextRecognizerModelType } from '@react-native-firebase/ml-vision';
|
||||
|
||||
console.log(VisionCloudTextRecognizerModelType.SPARSE_MODEL);
|
||||
|
||||
//
|
||||
// const foo = async () => {
|
||||
// const task = firebase
|
||||
// .app()
|
||||
// .storage('gs://foo')
|
||||
// .ref('foo')
|
||||
// .putFile('');
|
||||
//
|
||||
// task.on(firebase.storage.TaskEvent.STATE_CHANGED, taskSnapshot => {
|
||||
// if (taskSnapshot.state === firebase.storage.TaskState.) {
|
||||
// console.log('cancelling task!');
|
||||
// taskSnapshot.task.cancel();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// task.catch(e => {
|
||||
// return 'bar';
|
||||
// });
|
||||
//
|
||||
// task.then(snapshot => {
|
||||
// snapshot.metadata.bucket;
|
||||
// return 'foo';
|
||||
// });
|
||||
//
|
||||
// firebase.storage.TaskState.CANCELLED;
|
||||
// firebase.storage.TaskEvent.STATE_CHANGED;
|
||||
// firebase.perf().newHttpMetric('', 'GET');
|
||||
// // firebase.functions.HttpsErrorCode.ABORTED;
|
||||
// };
|
||||
//
|
||||
// foo();
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"include": ["packages/**/lib/*.d.ts", "packages/app-types/index.d.ts"],
|
||||
"include": ["packages/**/lib/*.d.ts", "packages/**/type-test.ts"],
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
|
||||
Reference in New Issue
Block a user