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 UpdateData typing fix #7255

Closed
wants to merge 12 commits into from
6 changes: 6 additions & 0 deletions .changeset/two-moles-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@firebase/firestore': major
'firebase': major
---

Fix typing issues with UpdateData in updateDoc(), Transaction.update(), and WriteBatch.update()
132 changes: 65 additions & 67 deletions common/api-review/firestore-lite.api.md

Large diffs are not rendered by default.

170 changes: 84 additions & 86 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, AppType = DocumentData, DbType extends DocumentData = AppType extends DocumentData ? AppType : 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;AppType, DbType&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<AppType, DbType>;
```

## 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.

18 changes: 9 additions & 9 deletions docs-devsite/firestore_.collectionreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ 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<AppType = DocumentData, DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData> extends Query<AppType, DbType>
```
<b>Extends:</b> [Query](./firestore_.query.md#query_class)<!-- -->&lt;T&gt;
<b>Extends:</b> [Query](./firestore_.query.md#query_class)<!-- -->&lt;AppType, DbType&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_.md#documentdata)<!-- -->, [DocumentData](./firestore_.md#documentdata)<!-- -->&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. |

Expand Down Expand Up @@ -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 Down Expand Up @@ -82,18 +82,18 @@ Applies a custom data converter to this `CollectionReference`<!-- -->, allowing
<b>Signature:</b>

```typescript
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
withConverter<NewAppType = DocumentData, NewDbType extends DocumentData = NewAppType extends DocumentData ? NewAppType : DocumentData>(converter: FirestoreDataConverter<NewAppType, NewDbType>): CollectionReference<NewAppType, NewDbType>;
```

### 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;NewAppType, NewDbType&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;NewAppType, NewDbType&gt;

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

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_.md#documentdata)<!-- -->, [DocumentData](./firestore_.md#documentdata)<!-- -->&gt;

A `CollectionReference<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<AppType = DocumentData, DbType extends DocumentData = AppType extends DocumentData ? AppType : 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;AppType, DbType&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<AppType, DbType>;
```

## DocumentChange.newIndex
Expand Down
19 changes: 0 additions & 19 deletions docs-devsite/firestore_.documentdata.md

This file was deleted.

20 changes: 10 additions & 10 deletions docs-devsite/firestore_.documentreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ 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<AppType = DocumentData, DbType extends DocumentData = AppType extends DocumentData ? AppType : 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;AppType, DbType&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;AppType, DbType&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. |

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<AppType, DbType> | 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<AppType, DbType>;
```

## DocumentReference.path
Expand Down Expand Up @@ -103,18 +103,18 @@ Applies a custom data converter to this `DocumentReference`<!-- -->, allowing yo
<b>Signature:</b>

```typescript
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
withConverter<NewAppType = DocumentData, NewDbType extends DocumentData = NewAppType extends DocumentData ? NewAppType : DocumentData>(converter: FirestoreDataConverter<NewAppType, NewDbType>): DocumentReference<NewAppType, NewDbType>;
```

### 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;NewAppType, NewDbType&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;NewAppType, NewDbType&gt;

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

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_.md#documentdata)<!-- -->, [DocumentData](./firestore_.md#documentdata)<!-- -->&gt;

A `DocumentReference<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<AppType = DocumentData, DbType extends DocumentData = AppType extends DocumentData ? AppType : 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;AppType, DbType&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<AppType, DbType>;
```

## 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): AppType | undefined;
```

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

<b>Returns:</b>

T \| undefined
AppType \| 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<AppType, DbType>;
```
<b>Returns:</b>

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

## DocumentSnapshot.get()

Expand Down
Loading