Address typing issues:
- Remove constructors intended to be private, and convert classes to interfaces - Allow 'false' for QueryListenOptions and DocumentListenOptions properites
This commit is contained in:
parent
578198e2e6
commit
80be7474ff
95
lib/index.d.ts
vendored
95
lib/index.d.ts
vendored
@ -79,7 +79,9 @@ declare module "react-native-firebase" {
|
|||||||
* Database. Comparison of the two products hers:
|
* Database. Comparison of the two products hers:
|
||||||
* https://firebase.google.com/docs/database/rtdb-vs-firestore
|
* https://firebase.google.com/docs/database/rtdb-vs-firestore
|
||||||
*/
|
*/
|
||||||
firestore(): RNFirebase.firestore.FirestoreModule;
|
static firestore: {
|
||||||
|
(): RNFirebase.firestore.Firestore;
|
||||||
|
} & RNFirebase.firestore.FirestoreStatics;
|
||||||
|
|
||||||
static fabric: {
|
static fabric: {
|
||||||
crashlytics(): RNFirebase.crashlytics.Crashlytics;
|
crashlytics(): RNFirebase.crashlytics.Crashlytics;
|
||||||
@ -1078,19 +1080,17 @@ declare module "react-native-firebase" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace firestore {
|
namespace firestore {
|
||||||
type FirestoreModule = Firestore & FirestoreStatics;
|
|
||||||
|
|
||||||
interface Firestore {
|
interface Firestore {
|
||||||
batch(): WriteBatch;
|
batch(): WriteBatch;
|
||||||
collection(collectionPath: string): CollectionReference;
|
collection(collectionPath: string): CollectionReference;
|
||||||
doc(documentPath: string): DocumentReference;
|
doc(documentPath: string): DocumentReference;
|
||||||
|
|
||||||
/** NOT SUPPORTED YET */
|
/** NOT SUPPORTED YET */
|
||||||
enablePersistence(): Promise<void>;
|
// enablePersistence(): Promise<void>;
|
||||||
/** NOT SUPPORTED YET */
|
/** NOT SUPPORTED YET */
|
||||||
runTransaction(): Promise<any>;
|
// runTransaction(): Promise<any>;
|
||||||
/** NOT SUPPORTED YET */
|
/** NOT SUPPORTED YET */
|
||||||
settings(): void;
|
// settings(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FirestoreStatics {
|
interface FirestoreStatics {
|
||||||
@ -1100,11 +1100,10 @@ declare module "react-native-firebase" {
|
|||||||
enableLogging(enabled: boolean): void;
|
enableLogging(enabled: boolean): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CollectionReference {
|
interface CollectionReference {
|
||||||
constructor(firestore: Firestore, collectionPath: Path);
|
readonly firestore: Firestore;
|
||||||
get firestore(): Firestore;
|
readonly id: string;
|
||||||
get id(): string;
|
readonly parent: DocumentReference;
|
||||||
get parent(): DocumentReference;
|
|
||||||
add(data: object): Promise<DocumentReference>;
|
add(data: object): Promise<DocumentReference>;
|
||||||
doc(documentPath?: string): DocumentReference;
|
doc(documentPath?: string): DocumentReference;
|
||||||
endAt(snapshot: DocumentSnapshot): Query;
|
endAt(snapshot: DocumentSnapshot): Query;
|
||||||
@ -1125,20 +1124,18 @@ declare module "react-native-firebase" {
|
|||||||
where(fieldPath: string, op: Types.QueryOperator, value: any): Query;
|
where(fieldPath: string, op: Types.QueryOperator, value: any): Query;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DocumentChange {
|
interface DocumentChange {
|
||||||
constructor(firestore: Firestore, nativeData: Types.NativeDocumentChange);
|
readonly doc: DocumentSnapshot;
|
||||||
get doc(): DocumentSnapshot;
|
readonly newIndex: number;
|
||||||
get newIndex(): number;
|
readonly oldIndex: number;
|
||||||
get oldIndex(): number;
|
readonly type: string;
|
||||||
get type(): string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DocumentReference {
|
interface DocumentReference {
|
||||||
constructor(firestore: Firestore, documentPath: Path);
|
readonly firestore: Firestore;
|
||||||
get firestore(): Firestore;
|
readonly id: string | null;
|
||||||
get id(): string | null;
|
readonly parent: CollectionReference;
|
||||||
get parent(): CollectionReference;
|
readonly path: string;
|
||||||
get path(): string;
|
|
||||||
collection(collectionPath: string): CollectionReference;
|
collection(collectionPath: string): CollectionReference;
|
||||||
delete(): Promise<void>;
|
delete(): Promise<void>;
|
||||||
get(): Promise<DocumentSnapshot>;
|
get(): Promise<DocumentSnapshot>;
|
||||||
@ -1155,9 +1152,8 @@ declare module "react-native-firebase" {
|
|||||||
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any, key5: Types.UpdateKey, val5: any): Promise<void>;
|
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any, key5: Types.UpdateKey, val5: any): Promise<void>;
|
||||||
}
|
}
|
||||||
namespace DocumentReference {
|
namespace DocumentReference {
|
||||||
// JS code expects this value to be true.
|
|
||||||
interface DocumentListenOptions {
|
interface DocumentListenOptions {
|
||||||
includeMetadataChanges: true;
|
includeMetadataChanges: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void;
|
type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void;
|
||||||
@ -1168,12 +1164,11 @@ declare module "react-native-firebase" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DocumentSnapshot {
|
interface DocumentSnapshot {
|
||||||
constructor(firestore: Firestore, nativeData: Types.NativeDocumentSnapshot)
|
readonly exists: boolean;
|
||||||
get exists(): boolean;
|
readonly id: string | null;
|
||||||
get id(): string | null;
|
readonly metadata: Types.SnapshotMetadata;
|
||||||
get metadata(): Types.SnapshotMetadata;
|
readonly ref: DocumentReference;
|
||||||
get ref(): DocumentReference;
|
|
||||||
data(): object | void;
|
data(): object | void;
|
||||||
get(fieldPath: string | FieldPath): any | undefined;
|
get(fieldPath: string | FieldPath): any | undefined;
|
||||||
}
|
}
|
||||||
@ -1205,15 +1200,8 @@ declare module "react-native-firebase" {
|
|||||||
parent(): Path | null;
|
parent(): Path | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Query {
|
interface Query {
|
||||||
constructor(
|
readonly firestore: Firestore;
|
||||||
firestore: Firestore,
|
|
||||||
path: Path,
|
|
||||||
fieldFilters?: Query.FieldFilter[],
|
|
||||||
fieldOrders?: Query.FieldOrder[],
|
|
||||||
queryOptions?: Query.QueryOptions,
|
|
||||||
);
|
|
||||||
get firestore(): Firestore;
|
|
||||||
endAt(snapshot: DocumentSnapshot): Query;
|
endAt(snapshot: DocumentSnapshot): Query;
|
||||||
endAt(...varargs: any[]): Query;
|
endAt(...varargs: any[]): Query;
|
||||||
endBefore(snapshot: DocumentSnapshot): Query;
|
endBefore(snapshot: DocumentSnapshot): Query;
|
||||||
@ -1221,7 +1209,7 @@ declare module "react-native-firebase" {
|
|||||||
get(): Promise<QuerySnapshot>;
|
get(): Promise<QuerySnapshot>;
|
||||||
limit(limit: number): Query;
|
limit(limit: number): Query;
|
||||||
onSnapshot(onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
onSnapshot(onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||||
onSnapshot(observer: Observer): () => void;
|
onSnapshot(observer: Query.Observer): () => void;
|
||||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
onSnapshot(queryListenOptions: Query.QueryListenOptions, onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, observer: Query.Observer): () => void;
|
onSnapshot(queryListenOptions: Query.QueryListenOptions, observer: Query.Observer): () => void;
|
||||||
orderBy(fieldPath: string | FieldPath, directionStr?: Types.QueryDirection): Query;
|
orderBy(fieldPath: string | FieldPath, directionStr?: Types.QueryDirection): Query;
|
||||||
@ -1260,13 +1248,12 @@ declare module "react-native-firebase" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The JS code expects at least one of 'includeDocumentMetadataChanges'
|
// The JS code expects at least one of 'includeDocumentMetadataChanges'
|
||||||
// or 'includeQueryMetadataChanges' to be true. This logic is
|
// or 'includeQueryMetadataChanges' to be defined.
|
||||||
// encapsulated in QueryListenOptions.
|
|
||||||
interface _IncludeDocumentMetadataChanges {
|
interface _IncludeDocumentMetadataChanges {
|
||||||
includeDocumentMetadataChanges: true;
|
includeDocumentMetadataChanges: boolean;
|
||||||
}
|
}
|
||||||
interface _IncludeQueryMetadataChanges {
|
interface _IncludeQueryMetadataChanges {
|
||||||
includeQueryMetadataChanges: true
|
includeQueryMetadataChanges: boolean;
|
||||||
}
|
}
|
||||||
type QueryListenOptions = _IncludeDocumentMetadataChanges | _IncludeQueryMetadataChanges | (_IncludeDocumentMetadataChanges & _IncludeQueryMetadataChanges);
|
type QueryListenOptions = _IncludeDocumentMetadataChanges | _IncludeQueryMetadataChanges | (_IncludeDocumentMetadataChanges & _IncludeQueryMetadataChanges);
|
||||||
|
|
||||||
@ -1278,14 +1265,13 @@ declare module "react-native-firebase" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class QuerySnapshot {
|
interface QuerySnapshot {
|
||||||
constructor(firestore: Firestore, query: Query, nativeData: QuerySnapshot.NativeData);
|
readonly docChanges: DocumentChange[];
|
||||||
get docChanges(): DocumentChange[];
|
readonly docs: DocumentSnapshot[];
|
||||||
get docs(): DocumentSnapshot[];
|
readonly empty: boolean;
|
||||||
get empty(): boolean;
|
readonly metadata: Types.SnapshotMetadata;
|
||||||
get metadata(): Types.SnapshotMetadata;
|
readonly query: Query;
|
||||||
get query(): Query;
|
readonly size: number;
|
||||||
get size(): number;
|
|
||||||
forEach(callback: (snapshot: DocumentSnapshot) => any);
|
forEach(callback: (snapshot: DocumentSnapshot) => any);
|
||||||
}
|
}
|
||||||
namespace QuerySnapshot {
|
namespace QuerySnapshot {
|
||||||
@ -1296,8 +1282,7 @@ declare module "react-native-firebase" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WriteBatch {
|
interface WriteBatch {
|
||||||
constructor(firestore: Firestore);
|
|
||||||
commit(): Promise<void>;
|
commit(): Promise<void>;
|
||||||
delete(docRef: DocumentReference): WriteBatch;
|
delete(docRef: DocumentReference): WriteBatch;
|
||||||
set(docRef: DocumentReference, data: object, options?: Types.WriteOptions): WriteBatch;
|
set(docRef: DocumentReference, data: object, options?: Types.WriteOptions): WriteBatch;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user