Merge pull request #421 from levibotelho/update-database-types

Update database TypeScript types
This commit is contained in:
Michael Diarmid 2017-09-18 13:57:06 +01:00 committed by GitHub
commit e538549286
1 changed files with 19 additions and 11 deletions

30
index.d.ts vendored
View File

@ -307,22 +307,27 @@ declare module "react-native-firebase" {
[key: string]: any; [key: string]: any;
} }
type QueryEventType = "value" | "child_added" | "child_removed" | "child_changed" | "child_moved";
type QuerySuccessCallback = (snapshot: DataSnapshot, previousChildId?: string | null) => void;
type QueryErrorCallback = (e: Error) => void;
interface Query { interface Query {
endAt(value: number | string | boolean | null, key?: string): database.Query; endAt(value: number | string | boolean | null, key?: string): database.Query;
equalTo(value: number | string | boolean | null, key?: string): database.Query; equalTo(value: number | string | boolean | null, key?: string): database.Query;
isEqual(other: database.Query | null): boolean; isEqual(other: database.Query | null): boolean;
limitToFirst(limit: number): database.Query; limitToFirst(limit: number): database.Query;
limitToLast(limit: number): database.Query; limitToLast(limit: number): database.Query;
off(eventType?: string, off(eventType?: QueryEventType,
callback?: (a: database.DataSnapshot, b?: string | null) => any, callback?: QuerySuccessCallback,
context?: Object | null): any; context?: Object): void;
on(eventType: string, on(eventType: QueryEventType,
callback: (a: database.DataSnapshot | null, b?: string) => any, callback: QuerySuccessCallback,
cancelCallbackOrContext?: Object | null, context?: Object | null): (a: database.DataSnapshot | null, b?: string) => any; cancelCallbackOrContext?: QueryErrorCallback,
once(eventType: string, context?: Object): (a: database.DataSnapshot | null, b?: string) => QuerySuccessCallback;
successCallback?: (a: database.DataSnapshot, b?: string) => any, once(eventType: QueryEventType,
failureCallbackOrContext?: Object | null, successCallback?: QuerySuccessCallback,
context?: Object | null): Promise<any>; failureCallbackOrContext?: QueryErrorCallback,
context?: Object): Promise<DataSnapshot>;
orderByChild(path: string): database.Query; orderByChild(path: string): database.Query;
orderByKey(): database.Query; orderByKey(): database.Query;
orderByPriority(): database.Query; orderByPriority(): database.Query;
@ -348,12 +353,15 @@ declare module "react-native-firebase" {
val(): any; val(): any;
} }
interface ThenableReference<T> extends Promise<T> {}
interface ThenableReference<T> extends Reference {}
interface Reference extends database.Query { interface Reference extends database.Query {
child(path: string): database.Reference; child(path: string): database.Reference;
key: string | null; key: string | null;
onDisconnect(): any; onDisconnect(): any;
parent: database.Reference | null; parent: database.Reference | null;
push(value?: any, onComplete?: (a: RnError | null) => any): any push(value?: any, onComplete?: (a: RnError | null) => any): ThenableReference<any>
remove(onComplete?: (a: RnError | null) => any): Promise<any>; remove(onComplete?: (a: RnError | null) => any): Promise<any>;
root: database.Reference; root: database.Reference;
set(value: any, onComplete?: (a: RnError | null) => any): Promise<any>; set(value: any, onComplete?: (a: RnError | null) => any): Promise<any>;