Skip to content

Commit 26767cd

Browse files
Misc fixes for firestore-exp API definition (#3359)
1 parent 064cf2e commit 26767cd

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

.changeset/tough-donkeys-hope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/firestore/exp/index.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export function setLogLevel(logLevel: LogLevel): void;
6565
export interface FirestoreDataConverter<T> {
6666
toFirestore(modelObject: T): DocumentData;
6767
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
68-
fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>): T;
68+
fromFirestore(
69+
snapshot: QueryDocumentSnapshot<DocumentData>,
70+
options: SnapshotOptions
71+
): T;
6972
}
7073

7174
export class FirebaseFirestore {
@@ -219,10 +222,13 @@ export class WriteBatch {
219222
commit(): Promise<void>;
220223
}
221224

222-
export interface SetOptions {
223-
readonly merge?: boolean;
224-
readonly mergeFields?: Array<string | FieldPath>;
225-
}
225+
export type SetOptions =
226+
| {
227+
readonly merge?: boolean;
228+
}
229+
| {
230+
readonly mergeFields?: Array<string | FieldPath>;
231+
};
226232

227233
export class DocumentReference<T = DocumentData> {
228234
private constructor();
@@ -249,7 +255,7 @@ export class DocumentSnapshot<T = DocumentData> {
249255
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<
250256
T
251257
> {
252-
data(): T;
258+
data(options?: SnapshotOptions): T;
253259
}
254260

255261
export type OrderByDirection = 'desc' | 'asc';

packages/firestore/lite/index.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,13 @@ export class WriteBatch {
183183
commit(): Promise<void>;
184184
}
185185

186-
export interface SetOptions {
187-
readonly merge?: boolean;
188-
readonly mergeFields?: Array<string | FieldPath>;
189-
}
186+
export type SetOptions =
187+
| {
188+
readonly merge?: boolean;
189+
}
190+
| {
191+
readonly mergeFields?: Array<string | FieldPath>;
192+
};
190193

191194
export class DocumentReference<T = DocumentData> {
192195
private constructor();

packages/firestore/lite/src/api/snapshot.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import { DocumentKey } from '../../../src/model/document_key';
2525
import { Document } from '../../../src/model/document';
2626
import { UserDataWriter } from '../../../src/api/user_data_writer';
2727
import { FieldPath as InternalFieldPath } from '../../../src/model/path';
28-
import { fieldPathFromDotSeparatedString } from '../../../src/api/user_data_reader';
28+
import {
29+
fieldPathFromDotSeparatedString,
30+
UntypedFirestoreDataConverter
31+
} from '../../../src/api/user_data_reader';
2932
import { arrayEquals } from '../../../src/util/misc';
3033

3134
export class DocumentSnapshot<T = firestore.DocumentData>
@@ -39,7 +42,7 @@ export class DocumentSnapshot<T = firestore.DocumentData>
3942
public _firestore: Firestore,
4043
public _key: DocumentKey,
4144
public _document: Document | null,
42-
public _converter: firestore.FirestoreDataConverter<T> | null
45+
public _converter: UntypedFirestoreDataConverter<T> | null
4346
) {}
4447

4548
get id(): string {

0 commit comments

Comments
 (0)