Skip to content

Misc fixes for firestore-exp API definition #3359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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