Skip to content

Commit

Permalink
Misc fixes for firestore-exp API definition (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Jul 7, 2020
1 parent 064cf2e commit 26767cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .changeset/tough-donkeys-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
18 changes: 12 additions & 6 deletions packages/firestore/exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export function setLogLevel(logLevel: LogLevel): void;
export interface FirestoreDataConverter<T> {
toFirestore(modelObject: T): DocumentData;
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>): T;
fromFirestore(
snapshot: QueryDocumentSnapshot<DocumentData>,
options: SnapshotOptions
): T;
}

export class FirebaseFirestore {
Expand Down Expand Up @@ -219,10 +222,13 @@ export class WriteBatch {
commit(): Promise<void>;
}

export interface SetOptions {
readonly merge?: boolean;
readonly mergeFields?: Array<string | FieldPath>;
}
export type SetOptions =
| {
readonly merge?: boolean;
}
| {
readonly mergeFields?: Array<string | FieldPath>;
};

export class DocumentReference<T = DocumentData> {
private constructor();
Expand All @@ -249,7 +255,7 @@ export class DocumentSnapshot<T = DocumentData> {
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<
T
> {
data(): T;
data(options?: SnapshotOptions): T;
}

export type OrderByDirection = 'desc' | 'asc';
Expand Down
11 changes: 7 additions & 4 deletions packages/firestore/lite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,13 @@ export class WriteBatch {
commit(): Promise<void>;
}

export interface SetOptions {
readonly merge?: boolean;
readonly mergeFields?: Array<string | FieldPath>;
}
export type SetOptions =
| {
readonly merge?: boolean;
}
| {
readonly mergeFields?: Array<string | FieldPath>;
};

export class DocumentReference<T = DocumentData> {
private constructor();
Expand Down
7 changes: 5 additions & 2 deletions packages/firestore/lite/src/api/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { DocumentKey } from '../../../src/model/document_key';
import { Document } from '../../../src/model/document';
import { UserDataWriter } from '../../../src/api/user_data_writer';
import { FieldPath as InternalFieldPath } from '../../../src/model/path';
import { fieldPathFromDotSeparatedString } from '../../../src/api/user_data_reader';
import {
fieldPathFromDotSeparatedString,
UntypedFirestoreDataConverter
} from '../../../src/api/user_data_reader';
import { arrayEquals } from '../../../src/util/misc';

export class DocumentSnapshot<T = firestore.DocumentData>
Expand All @@ -39,7 +42,7 @@ export class DocumentSnapshot<T = firestore.DocumentData>
public _firestore: Firestore,
public _key: DocumentKey,
public _document: Document | null,
public _converter: firestore.FirestoreDataConverter<T> | null
public _converter: UntypedFirestoreDataConverter<T> | null
) {}

get id(): string {
Expand Down

0 comments on commit 26767cd

Please sign in to comment.