Skip to content
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

Firestore: Fix the updateDoc() incorrect parameter type issue #7310

Merged
merged 14 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
6 changes: 6 additions & 0 deletions .changeset/rude-terms-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@firebase/firestore': major
'firebase': major
---

Fixed updateDoc() typing issue by adding a 2nd type parameter to FirestoreDataConverter
136 changes: 68 additions & 68 deletions common/api-review/firestore-lite.api.md

Large diffs are not rendered by default.

174 changes: 87 additions & 87 deletions common/api-review/firestore.api.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs-devsite/firestore_.aggregatequerysnapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ The results of executing an aggregation query.
<b>Signature:</b>

```typescript
export declare class AggregateQuerySnapshot<T extends AggregateSpec>
export declare class AggregateQuerySnapshot<AggregateSpecType extends AggregateSpec, AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [query](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshotquery) | | [Query](./firestore_.query.md#query_class)<!-- -->&lt;unknown&gt; | The underlying query over which the aggregations recorded in this <code>AggregateQuerySnapshot</code> were performed. |
| [query](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshotquery) | | [Query](./firestore_.query.md#query_class)<!-- -->&lt;AppModelType, DbModelType&gt; | The underlying query over which the aggregations recorded in this <code>AggregateQuerySnapshot</code> were performed. |
| [type](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshottype) | | (not declared) | A type string to uniquely identify instances of this class. |

## Methods
Expand All @@ -38,7 +38,7 @@ The underlying query over which the aggregations recorded in this `AggregateQuer
<b>Signature:</b>

```typescript
readonly query: Query<unknown>;
readonly query: Query<AppModelType, DbModelType>;
```

## AggregateQuerySnapshot.type
Expand All @@ -60,11 +60,11 @@ The keys of the returned object will be the same as those of the `AggregateSpec`
<b>Signature:</b>

```typescript
data(): AggregateSpecData<T>;
data(): AggregateSpecData<AggregateSpecType>;
```
<b>Returns:</b>

[AggregateSpecData](./firestore_.md#aggregatespecdata)<!-- -->&lt;T&gt;
[AggregateSpecData](./firestore_.md#aggregatespecdata)<!-- -->&lt;AggregateSpecType&gt;

The results of the aggregations performed over the underlying query.

26 changes: 13 additions & 13 deletions docs-devsite/firestore_.collectionreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ A `CollectionReference` object can be used for adding documents, getting documen
<b>Signature:</b>

```typescript
export declare class CollectionReference<T = DocumentData> extends Query<T>
export declare class CollectionReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> extends Query<AppModelType, DbModelType>
```
<b>Extends:</b> [Query](./firestore_.query.md#query_class)<!-- -->&lt;T&gt;
<b>Extends:</b> [Query](./firestore_.query.md#query_class)<!-- -->&lt;AppModelType, DbModelType&gt;

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [id](./firestore_.collectionreference.md#collectionreferenceid) | | string | The collection's identifier. |
| [parent](./firestore_.collectionreference.md#collectionreferenceparent) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt; \| null | A reference to the containing <code>DocumentReference</code> if this is a subcollection. If this isn't a subcollection, the reference is null. |
| [parent](./firestore_.collectionreference.md#collectionreferenceparent) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt; \| null | A reference to the containing <code>DocumentReference</code> if this is a subcollection. If this isn't a subcollection, the reference is null. |
| [path](./firestore_.collectionreference.md#collectionreferencepath) | | string | A string representing the path of the referenced collection (relative to the root of the database). |
| [type](./firestore_.collectionreference.md#collectionreferencetype) | | (not declared) | The type of this Firestore reference. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Applies a custom data converter to this <code>CollectionReference</code>, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned <code>CollectionReference</code> instance, the provided converter will convert between Firestore data and your custom type <code>U</code>. |
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Applies a custom data converter to this <code>CollectionReference</code>, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned <code>CollectionReference</code> instance, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
| [withConverter(converter)](./firestore_.collectionreference.md#collectionreferencewithconverter) | | Removes the current converter. |

## CollectionReference.id
Expand All @@ -52,7 +52,7 @@ A reference to the containing `DocumentReference` if this is a subcollection. If
<b>Signature:</b>

```typescript
get parent(): DocumentReference<DocumentData> | null;
get parent(): DocumentReference<DocumentData, DocumentData> | null;
```

## CollectionReference.path
Expand All @@ -77,25 +77,25 @@ readonly type = "collection";

## CollectionReference.withConverter()

Applies a custom data converter to this `CollectionReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned `CollectionReference` instance, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
Applies a custom data converter to this `CollectionReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [addDoc()](./firestore_.md#adddoc) with the returned `CollectionReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.

<b>Signature:</b>

```typescript
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
withConverter<NewAppModelType, NewDbModelType extends DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): CollectionReference<NewAppModelType, NewDbModelType>;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;U&gt; | Converts objects to and from Firestore. |
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;NewAppModelType, NewDbModelType&gt; | Converts objects to and from Firestore. |

<b>Returns:</b>

[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;U&gt;
[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;

A `CollectionReference<U>` that uses the provided converter.
A `CollectionReference` that uses the provided converter.

## CollectionReference.withConverter()

Expand All @@ -104,7 +104,7 @@ Removes the current converter.
<b>Signature:</b>

```typescript
withConverter(converter: null): CollectionReference<DocumentData>;
withConverter(converter: null): CollectionReference<DocumentData, DocumentData>;
```

### Parameters
Expand All @@ -115,7 +115,7 @@ withConverter(converter: null): CollectionReference<DocumentData>;

<b>Returns:</b>

[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;
[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;

A `CollectionReference<DocumentData>` that does not use a converter.
A `CollectionReference<DocumentData, DocumentData>` that does not use a converter.

6 changes: 3 additions & 3 deletions docs-devsite/firestore_.documentchange.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ A `DocumentChange` represents a change to the documents matching a query. It con
<b>Signature:</b>

```typescript
export declare interface DocumentChange<T = DocumentData>
export declare interface DocumentChange<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [doc](./firestore_.documentchange.md#documentchangedoc) | [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)<!-- -->&lt;T&gt; | The document affected by this change. |
| [doc](./firestore_.documentchange.md#documentchangedoc) | [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt; | The document affected by this change. |
| [newIndex](./firestore_.documentchange.md#documentchangenewindex) | number | The index of the changed document in the result set immediately after this <code>DocumentChange</code> (i.e. supposing that all prior <code>DocumentChange</code> objects and the current <code>DocumentChange</code> object have been applied). Is -1 for 'removed' events. |
| [oldIndex](./firestore_.documentchange.md#documentchangeoldindex) | number | The index of the changed document in the result set immediately prior to this <code>DocumentChange</code> (i.e. supposing that all prior <code>DocumentChange</code> objects have been applied). Is <code>-1</code> for 'added' events. |
| [type](./firestore_.documentchange.md#documentchangetype) | [DocumentChangeType](./firestore_.md#documentchangetype) | The type of change ('added', 'modified', or 'removed'). |
Expand All @@ -34,7 +34,7 @@ The document affected by this change.
<b>Signature:</b>

```typescript
readonly doc: QueryDocumentSnapshot<T>;
readonly doc: QueryDocumentSnapshot<AppModelType, DbModelType>;
```

## DocumentChange.newIndex
Expand Down
28 changes: 14 additions & 14 deletions docs-devsite/firestore_.documentreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ A `DocumentReference` refers to a document location in a Firestore database and
<b>Signature:</b>

```typescript
export declare class DocumentReference<T = DocumentData>
export declare class DocumentReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [converter](./firestore_.documentreference.md#documentreferenceconverter) | | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;T&gt; \| null | If provided, the <code>FirestoreDataConverter</code> associated with this instance. |
| [converter](./firestore_.documentreference.md#documentreferenceconverter) | | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;AppModelType, DbModelType&gt; \| null | If provided, the <code>FirestoreDataConverter</code> associated with this instance. |
| [firestore](./firestore_.documentreference.md#documentreferencefirestore) | | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the document is in. This is useful for performing transactions, for example. |
| [id](./firestore_.documentreference.md#documentreferenceid) | | string | The document's identifier within its collection. |
| [parent](./firestore_.documentreference.md#documentreferenceparent) | | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;T&gt; | The collection this <code>DocumentReference</code> belongs to. |
| [parent](./firestore_.documentreference.md#documentreferenceparent) | | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<!-- -->&lt;AppModelType, DbModelType&gt; | The collection this <code>DocumentReference</code> belongs to. |
| [path](./firestore_.documentreference.md#documentreferencepath) | | string | A string representing the path of the referenced document (relative to the root of the database). |
| [type](./firestore_.documentreference.md#documentreferencetype) | | (not declared) | The type of this Firestore reference. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this <code>DocumentReference</code>, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned <code>DocumentReference</code> instance, the provided converter will convert between Firestore data and your custom type <code>U</code>. |
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this <code>DocumentReference</code>, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned <code>DocumentReference</code> instance, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Removes the current converter. |

## DocumentReference.converter
Expand All @@ -43,7 +43,7 @@ If provided, the `FirestoreDataConverter` associated with this instance.
<b>Signature:</b>

```typescript
readonly converter: FirestoreDataConverter<T> | null;
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
```

## DocumentReference.firestore
Expand Down Expand Up @@ -73,7 +73,7 @@ The collection this `DocumentReference` belongs to.
<b>Signature:</b>

```typescript
get parent(): CollectionReference<T>;
get parent(): CollectionReference<AppModelType, DbModelType>;
```

## DocumentReference.path
Expand All @@ -98,25 +98,25 @@ readonly type = "document";

## DocumentReference.withConverter()

Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data and your custom type `U`<!-- -->.
Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc)<!-- -->, [getDoc()](./firestore_lite.md#getdoc)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.

<b>Signature:</b>

```typescript
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
withConverter<NewAppModelType, NewDbModelType extends DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
```

### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;U&gt; | Converts objects to and from Firestore. |
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;NewAppModelType, NewDbModelType&gt; | Converts objects to and from Firestore. |

<b>Returns:</b>

[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;U&gt;
[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;

A `DocumentReference<U>` that uses the provided converter.
A `DocumentReference` that uses the provided converter.

## DocumentReference.withConverter()

Expand All @@ -125,7 +125,7 @@ Removes the current converter.
<b>Signature:</b>

```typescript
withConverter(converter: null): DocumentReference<DocumentData>;
withConverter(converter: null): DocumentReference<DocumentData, DocumentData>;
```

### Parameters
Expand All @@ -136,7 +136,7 @@ withConverter(converter: null): DocumentReference<DocumentData>;

<b>Returns:</b>

[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;
[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;[DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->, [DocumentData](./firestore_.documentdata.md#documentdata_interface)<!-- -->&gt;

A `DocumentReference<DocumentData>` that does not use a converter.
A `DocumentReference<DocumentData, DocumentData>` that does not use a converter.

14 changes: 7 additions & 7 deletions docs-devsite/firestore_.documentsnapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For a `DocumentSnapshot` that points to a non-existing document, any data access
<b>Signature:</b>

```typescript
export declare class DocumentSnapshot<T = DocumentData>
export declare class DocumentSnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
```

## Constructors
Expand All @@ -32,7 +32,7 @@ export declare class DocumentSnapshot<T = DocumentData>
| --- | --- | --- | --- |
| [id](./firestore_.documentsnapshot.md#documentsnapshotid) | | string | Property of the <code>DocumentSnapshot</code> that provides the document's ID. |
| [metadata](./firestore_.documentsnapshot.md#documentsnapshotmetadata) | | [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about the <code>DocumentSnapshot</code>, including information about its source and local modifications. |
| [ref](./firestore_.documentsnapshot.md#documentsnapshotref) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;T&gt; | The <code>DocumentReference</code> for the document included in the <code>DocumentSnapshot</code>. |
| [ref](./firestore_.documentsnapshot.md#documentsnapshotref) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;AppModelType, DbModelType&gt; | The <code>DocumentReference</code> for the document included in the <code>DocumentSnapshot</code>. |

## Methods

Expand Down Expand Up @@ -79,7 +79,7 @@ The `DocumentReference` for the document included in the `DocumentSnapshot`<!--
<b>Signature:</b>

```typescript
get ref(): DocumentReference<T>;
get ref(): DocumentReference<AppModelType, DbModelType>;
```

## DocumentSnapshot.data()
Expand All @@ -91,7 +91,7 @@ By default, `serverTimestamp()` values that have not yet been set to their final
<b>Signature:</b>

```typescript
data(options?: SnapshotOptions): T | undefined;
data(options?: SnapshotOptions): AppModelType | undefined;
```

### Parameters
Expand All @@ -102,7 +102,7 @@ data(options?: SnapshotOptions): T | undefined;

<b>Returns:</b>

T \| undefined
AppModelType \| undefined

An `Object` containing all fields in the document or `undefined` if the document doesn't exist.

Expand All @@ -113,11 +113,11 @@ Returns whether or not the data exists. True if the document exists.
<b>Signature:</b>

```typescript
exists(): this is QueryDocumentSnapshot<T>;
exists(): this is QueryDocumentSnapshot<AppModelType, DbModelType>;
```
<b>Returns:</b>

this is [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)<!-- -->&lt;T&gt;
this is [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class)<!-- -->&lt;AppModelType, DbModelType&gt;

## DocumentSnapshot.get()

Expand Down
Loading