diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index bd278bfbb9e..1beffdb6e8d 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -1429,7 +1429,7 @@ export class QueryDocumentSnapshot extends DocumentSnapshot typeof data === 'object', 'Document in a QueryDocumentSnapshot should exist' ); - return data as firestore.DocumentData; + return data; } } diff --git a/packages/firestore/src/api/user_data_converter.ts b/packages/firestore/src/api/user_data_converter.ts index 2c13587e9e8..f4b0094d8bd 100644 --- a/packages/firestore/src/api/user_data_converter.ts +++ b/packages/firestore/src/api/user_data_converter.ts @@ -505,7 +505,7 @@ export class UserDataConverter { context.fieldTransforms.length === 0, 'Field transforms should have been disallowed.' ); - return parsed!; + return parsed; } /** Sends data through this.preConverter, handling any thrown errors. */ diff --git a/packages/firestore/src/core/query.ts b/packages/firestore/src/core/query.ts index efe80c01f5f..2dd40fef850 100644 --- a/packages/firestore/src/core/query.ts +++ b/packages/firestore/src/core/query.ts @@ -524,12 +524,12 @@ export class FieldFilter extends Filter { 'Comparing on key with IN, but filter value not an ArrayValue' ); assert( - (value as ArrayValue).internalValue.every(elem => { + value.internalValue.every(elem => { return elem instanceof RefValue; }), 'Comparing on key with IN, but an array value was not a RefValue' ); - return new KeyFieldInFilter(field, value as ArrayValue); + return new KeyFieldInFilter(field, value); } else { assert( value instanceof RefValue, @@ -539,7 +539,7 @@ export class FieldFilter extends Filter { op !== Operator.ARRAY_CONTAINS && op !== Operator.ARRAY_CONTAINS_ANY, `'${op.toString()}' queries don't make sense on document keys.` ); - return new KeyFieldFilter(field, op, value as RefValue); + return new KeyFieldFilter(field, op, value); } } else if (value.isEqual(NullValue.INSTANCE)) { if (op !== Operator.EQUAL) { @@ -564,13 +564,13 @@ export class FieldFilter extends Filter { value instanceof ArrayValue, 'IN filter has invalid value: ' + value.toString() ); - return new InFilter(field, value as ArrayValue); + return new InFilter(field, value); } else if (op === Operator.ARRAY_CONTAINS_ANY) { assert( value instanceof ArrayValue, 'ARRAY_CONTAINS_ANY filter has invalid value: ' + value.toString() ); - return new ArrayContainsAnyFilter(field, value as ArrayValue); + return new ArrayContainsAnyFilter(field, value); } else { return new FieldFilter(field, op, value); } @@ -764,17 +764,14 @@ export class Bound { component instanceof RefValue, 'Bound has a non-key value where the key path is being used.' ); - comparison = DocumentKey.comparator( - (component as RefValue).key, - doc.key - ); + comparison = DocumentKey.comparator(component.key, doc.key); } else { const docValue = doc.field(orderByComponent.field); assert( docValue !== null, 'Field should exist since document matched the orderBy already.' ); - comparison = component.compareTo(docValue!); + comparison = component.compareTo(docValue); } if (orderByComponent.dir === Direction.DESCENDING) { comparison = comparison * -1; diff --git a/packages/firestore/src/core/sync_engine.ts b/packages/firestore/src/core/sync_engine.ts index fe994bf487f..2eccb47d2a2 100644 --- a/packages/firestore/src/core/sync_engine.ts +++ b/packages/firestore/src/core/sync_engine.ts @@ -980,7 +980,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { assert(!!queryView, `No query view found for ${query}`); const viewChange = await this.synchronizeViewAndComputeSnapshot( - queryView! + queryView ); if (viewChange.snapshot) { newViewSnapshots.push(viewChange.snapshot); @@ -995,7 +995,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { // allocate the target in LocalStore and initialize a new View. const target = await this.localStore.getTarget(targetId); assert(!!target, `Target for id ${targetId} not found`); - targetData = await this.localStore.allocateTarget(target!); + targetData = await this.localStore.allocateTarget(target); await this.initializeViewAndComputeSnapshot( this.synthesizeTargetToQuery(target!), targetId, @@ -1097,9 +1097,9 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { ); const target = await this.localStore.getTarget(targetId); assert(!!target, `Query data for active target ${targetId} not found`); - const targetData = await this.localStore.allocateTarget(target!); + const targetData = await this.localStore.allocateTarget(target); await this.initializeViewAndComputeSnapshot( - this.synthesizeTargetToQuery(target!), + this.synthesizeTargetToQuery(target), targetData.targetId, /*current=*/ false ); @@ -1151,7 +1151,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer { for (const query of queries) { const queryView = this.queryViewsByQuery.get(query); assert(!!queryView, `No query view found for ${query}`); - keySet = keySet.unionWith(queryView!.view.syncedDocuments); + keySet = keySet.unionWith(queryView.view.syncedDocuments); } return keySet; } diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index 3ddcc23edb3..f91023b8ed0 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -352,7 +352,7 @@ export class IndexedDbMutationQueue implements MutationQueue { mutation.userId === this.userId, `Unexpected user '${mutation.userId}' for mutation batch ${batchId}` ); - results.push(this.serializer.fromDbMutationBatch(mutation!)); + results.push(this.serializer.fromDbMutationBatch(mutation)); }); }) .next(() => results); @@ -483,7 +483,7 @@ export class IndexedDbMutationQueue implements MutationQueue { mutation.userId === this.userId, `Unexpected user '${mutation.userId}' for mutation batch ${batchId}` ); - results.push(this.serializer.fromDbMutationBatch(mutation!)); + results.push(this.serializer.fromDbMutationBatch(mutation)); }) ); }); diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index dfb47f9f96f..f59a7f546fa 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -949,7 +949,7 @@ export class IndexedDbPersistence implements Persistence { typeof this.document.addEventListener === 'function', "Expected 'document.addEventListener' to be a function" ); - this.document!.removeEventListener( + this.document.removeEventListener( 'visibilitychange', this.documentVisibilityHandler ); diff --git a/packages/firestore/src/local/indexeddb_target_cache.ts b/packages/firestore/src/local/indexeddb_target_cache.ts index 6fe07a69b4b..edbdc04b275 100644 --- a/packages/firestore/src/local/indexeddb_target_cache.ts +++ b/packages/firestore/src/local/indexeddb_target_cache.ts @@ -421,7 +421,7 @@ function retrieveMetadata( ); return globalStore.get(DbTargetGlobal.key).next(metadata => { assert(metadata !== null, 'Missing metadata row.'); - return metadata!; + return metadata; }); } diff --git a/packages/firestore/src/local/local_store.ts b/packages/firestore/src/local/local_store.ts index 6ee340a9e3a..37409d0b4ba 100644 --- a/packages/firestore/src/local/local_store.ts +++ b/packages/firestore/src/local/local_store.ts @@ -432,8 +432,8 @@ export class LocalStore { .lookupMutationBatch(txn, batchId) .next((batch: MutationBatch | null) => { assert(batch !== null, 'Attempt to reject nonexistent batch!'); - affectedKeys = batch!.keys(); - return this.mutationQueue.removeMutationBatch(txn, batch!); + affectedKeys = batch.keys(); + return this.mutationQueue.removeMutationBatch(txn, batch); }) .next(() => { return this.mutationQueue.performConsistencyCheck(txn); @@ -746,8 +746,8 @@ export class LocalStore { ); // Advance the last limbo free snapshot version - const lastLimboFreeSnapshotVersion = targetData!.snapshotVersion; - const updatedTargetData = targetData!.withLastLimboFreeSnapshotVersion( + const lastLimboFreeSnapshotVersion = targetData.snapshotVersion; + const updatedTargetData = targetData.withLastLimboFreeSnapshotVersion( lastLimboFreeSnapshotVersion ); this.targetDataByTarget = this.targetDataByTarget.insert( diff --git a/packages/firestore/src/local/memory_mutation_queue.ts b/packages/firestore/src/local/memory_mutation_queue.ts index c114d8e3d95..1c9c62eb280 100644 --- a/packages/firestore/src/local/memory_mutation_queue.ts +++ b/packages/firestore/src/local/memory_mutation_queue.ts @@ -158,7 +158,7 @@ export class MemoryMutationQueue implements MutationQueue { const mutationBatch = this.findMutationBatch(batchId); assert(mutationBatch != null, 'Failed to find local mutation batch.'); return PersistencePromise.resolve( - mutationBatch!.keys() + mutationBatch.keys() ); } diff --git a/packages/firestore/src/local/remote_document_change_buffer.ts b/packages/firestore/src/local/remote_document_change_buffer.ts index 2aed9e64f9d..dec6eec5658 100644 --- a/packages/firestore/src/local/remote_document_change_buffer.ts +++ b/packages/firestore/src/local/remote_document_change_buffer.ts @@ -82,7 +82,7 @@ export abstract class RemoteDocumentChangeBuffer { this._readTime !== undefined, 'Read time is not set. All removeEntry() calls must include a readTime if `trackRemovals` is used.' ); - return this._readTime!; + return this._readTime; } /** diff --git a/packages/firestore/src/local/shared_client_state.ts b/packages/firestore/src/local/shared_client_state.ts index 37bb0c842c4..558a142e547 100644 --- a/packages/firestore/src/local/shared_client_state.ts +++ b/packages/firestore/src/local/shared_client_state.ts @@ -963,7 +963,7 @@ export class WebStorageSharedClientState implements SharedClientState { ): RemoteClientState | null { const clientId = this.fromWebStorageClientStateKey(key); assert(clientId !== null, `Cannot parse client state key '${key}'`); - return RemoteClientState.fromWebStorageEntry(clientId!, value); + return RemoteClientState.fromWebStorageEntry(clientId, value); } /** @@ -977,8 +977,8 @@ export class WebStorageSharedClientState implements SharedClientState { const match = this.mutationBatchKeyRe.exec(key); assert(match !== null, `Cannot parse mutation batch key '${key}'`); - const batchId = Number(match![1]); - const userId = match![2] !== undefined ? match![2] : null; + const batchId = Number(match[1]); + const userId = match[2] !== undefined ? match[2] : null; return MutationMetadata.fromWebStorageEntry( new User(userId), batchId, @@ -997,7 +997,7 @@ export class WebStorageSharedClientState implements SharedClientState { const match = this.queryTargetKeyRe.exec(key); assert(match !== null, `Cannot parse query target key '${key}'`); - const targetId = Number(match![1]); + const targetId = Number(match[1]); return QueryTargetMetadata.fromWebStorageEntry(targetId, value); } diff --git a/packages/firestore/src/local/simple_query_engine.ts b/packages/firestore/src/local/simple_query_engine.ts index e43868a839f..b71b7cedf96 100644 --- a/packages/firestore/src/local/simple_query_engine.ts +++ b/packages/firestore/src/local/simple_query_engine.ts @@ -49,7 +49,7 @@ export class SimpleQueryEngine implements QueryEngine { // TODO: Once LocalDocumentsView provides a getCollectionDocuments() // method, we should call that here and then filter the results. - return this.localDocumentsView!.getDocumentsMatchingQuery( + return this.localDocumentsView.getDocumentsMatchingQuery( transaction, query, SnapshotVersion.MIN diff --git a/packages/firestore/src/model/mutation.ts b/packages/firestore/src/model/mutation.ts index 92a752cf45c..4ba967abee1 100644 --- a/packages/firestore/src/model/mutation.ts +++ b/packages/firestore/src/model/mutation.ts @@ -654,12 +654,11 @@ export class TransformMutation extends Mutation { maybeDoc instanceof Document, 'Unknown MaybeDocument type ' + maybeDoc ); - const doc = maybeDoc! as Document; assert( - doc.key.isEqual(this.key), + maybeDoc.key.isEqual(this.key), 'Can only transform a document with the same key' ); - return doc; + return maybeDoc; } /** diff --git a/packages/firestore/src/model/transform_operation.ts b/packages/firestore/src/model/transform_operation.ts index 036e6582866..4830f3af3be 100644 --- a/packages/firestore/src/model/transform_operation.ts +++ b/packages/firestore/src/model/transform_operation.ts @@ -219,7 +219,7 @@ export class NumericIncrementTransformOperation implements TransformOperation { transformResult !== null, "Didn't receive transformResult for NUMERIC_ADD transform" ); - return transformResult!; + return transformResult; } /** diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index d5623b71dd1..231bb775998 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -115,7 +115,7 @@ export class Datastore { keys.forEach(key => { const doc = docs.get(key); assert(!!doc, 'Missing entity in write response for ' + key); - result.push(doc!); + result.push(doc); }); return result; }); diff --git a/packages/firestore/src/remote/persistent_stream.ts b/packages/firestore/src/remote/persistent_stream.ts index d2be6097998..6a6435bdba2 100644 --- a/packages/firestore/src/remote/persistent_stream.ts +++ b/packages/firestore/src/remote/persistent_stream.ts @@ -698,7 +698,7 @@ export class PersistentWriteStream extends PersistentStream< !!responseProto.streamToken, 'Got a write response without a stream token' ); - this.lastStreamToken = responseProto.streamToken!; + this.lastStreamToken = responseProto.streamToken; if (!this.handshakeComplete_) { // The first response is always the handshake response diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 6d3ca59498a..5d86d7e0485 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -94,7 +94,7 @@ const OPERATORS = (() => { // A RegExp matching ISO 8601 UTC timestamps with optional fraction. const ISO_REG_EXP = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/); -function assertPresent(value: unknown, description: string): void { +function assertPresent(value: unknown, description: string): asserts value { assert(!typeUtils.isNullOrUndefined(value), description + ' is missing'); } @@ -257,9 +257,9 @@ export class JsonProtoSerializer { let nanos = 0; const fraction = ISO_REG_EXP.exec(utc); assert(!!fraction, 'invalid timestamp: ' + utc); - if (fraction![1]) { + if (fraction[1]) { // Pad the fraction out to 9 digits (nanos). - let nanoStr = fraction![1]; + let nanoStr = fraction[1]; nanoStr = (nanoStr + '000000000').substr(0, 9); nanos = Number(nanoStr); } @@ -490,7 +490,7 @@ export class JsonProtoSerializer { } else if ('arrayValue' in obj) { // "values" is not present if the array is empty assertPresent(obj.arrayValue, 'arrayValue'); - const values = obj.arrayValue!.values || []; + const values = obj.arrayValue.values || []; return new fieldValue.ArrayValue(values.map(v => this.fromValue(v))); } else if ('timestampValue' in obj) { assertPresent(obj.timestampValue, 'timestampValue'); @@ -499,16 +499,16 @@ export class JsonProtoSerializer { ); } else if ('geoPointValue' in obj) { assertPresent(obj.geoPointValue, 'geoPointValue'); - const latitude = obj.geoPointValue!.latitude || 0; - const longitude = obj.geoPointValue!.longitude || 0; + const latitude = obj.geoPointValue.latitude || 0; + const longitude = obj.geoPointValue.longitude || 0; return new fieldValue.GeoPointValue(new GeoPoint(latitude, longitude)); } else if ('bytesValue' in obj) { assertPresent(obj.bytesValue, 'bytesValue'); - const blob = this.fromBlob(obj.bytesValue!); + const blob = this.fromBlob(obj.bytesValue); return new fieldValue.BlobValue(blob); } else if ('referenceValue' in obj) { assertPresent(obj.referenceValue, 'referenceValue'); - const resourceName = this.fromResourceName(obj.referenceValue!); + const resourceName = this.fromResourceName(obj.referenceValue); const dbId = new DatabaseId(resourceName.get(1), resourceName.get(3)); const key = new DocumentKey( this.extractLocalPathFromResourceName(resourceName) @@ -595,11 +595,11 @@ export class JsonProtoSerializer { !!doc.found, 'Tried to deserialize a found document from a missing document.' ); - assertPresent(doc.found!.name, 'doc.found.name'); - assertPresent(doc.found!.updateTime, 'doc.found.updateTime'); - const key = this.fromName(doc.found!.name!); - const version = this.fromVersion(doc.found!.updateTime!); - return new Document(key, version, {}, undefined, doc.found!, v => + assertPresent(doc.found.name, 'doc.found.name'); + assertPresent(doc.found.updateTime, 'doc.found.updateTime'); + const key = this.fromName(doc.found.name); + const version = this.fromVersion(doc.found.updateTime); + return new Document(key, version, {}, undefined, doc.found, v => this.fromValue(v) ); } @@ -613,8 +613,8 @@ export class JsonProtoSerializer { !!result.readTime, 'Tried to deserialize a missing document without a read time.' ); - const key = this.fromName(result.missing!); - const version = this.fromVersion(result.readTime!); + const key = this.fromName(result.missing); + const version = this.fromVersion(result.readTime); return new NoDocument(key, version); } @@ -714,11 +714,11 @@ export class JsonProtoSerializer { // proto3 default value is unset in JSON (undefined), so use 'NO_CHANGE' // if unset const state = this.fromWatchTargetChangeState( - change.targetChange!.targetChangeType || 'NO_CHANGE' + change.targetChange.targetChangeType || 'NO_CHANGE' ); - const targetIds: TargetId[] = change.targetChange!.targetIds || []; + const targetIds: TargetId[] = change.targetChange.targetIds || []; const resumeToken = - change.targetChange!.resumeToken || this.emptyByteString(); + change.targetChange.resumeToken || this.emptyByteString(); const causeProto = change.targetChange!.cause; const cause = causeProto && this.fromRpcStatus(causeProto); watchChange = new WatchTargetChange( @@ -729,18 +729,15 @@ export class JsonProtoSerializer { ); } else if ('documentChange' in change) { assertPresent(change.documentChange, 'documentChange'); - assertPresent(change.documentChange!.document, 'documentChange.name'); + const entityChange = change.documentChange; + assertPresent(entityChange.document, 'documentChange.name'); + assertPresent(entityChange.document.name, 'documentChange.document.name'); assertPresent( - change.documentChange!.document!.name, - 'documentChange.document.name' - ); - assertPresent( - change.documentChange!.document!.updateTime, + entityChange.document.updateTime, 'documentChange.document.updateTime' ); - const entityChange = change.documentChange!; - const key = this.fromName(entityChange.document!.name!); - const version = this.fromVersion(entityChange.document!.updateTime!); + const key = this.fromName(entityChange.document.name); + const version = this.fromVersion(entityChange.document.updateTime); const doc = new Document( key, version, @@ -759,9 +756,9 @@ export class JsonProtoSerializer { ); } else if ('documentDelete' in change) { assertPresent(change.documentDelete, 'documentDelete'); - assertPresent(change.documentDelete!.document, 'documentDelete.document'); - const docDelete = change.documentDelete!; - const key = this.fromName(docDelete.document!); + const docDelete = change.documentDelete; + assertPresent(docDelete.document, 'documentDelete.document'); + const key = this.fromName(docDelete.document); const version = docDelete.readTime ? this.fromVersion(docDelete.readTime) : SnapshotVersion.forDeletedDoc(); @@ -770,19 +767,19 @@ export class JsonProtoSerializer { watchChange = new DocumentWatchChange([], removedTargetIds, doc.key, doc); } else if ('documentRemove' in change) { assertPresent(change.documentRemove, 'documentRemove'); - assertPresent(change.documentRemove!.document, 'documentRemove'); - const docRemove = change.documentRemove!; - const key = this.fromName(docRemove.document!); + const docRemove = change.documentRemove; + assertPresent(docRemove.document, 'documentRemove'); + const key = this.fromName(docRemove.document); const removedTargetIds = docRemove.removedTargetIds || []; watchChange = new DocumentWatchChange([], removedTargetIds, key, null); } else if ('filter' in change) { // TODO(dimond): implement existence filter parsing with strategy. assertPresent(change.filter, 'filter'); - assertPresent(change.filter!.targetId, 'filter.targetId'); const filter = change.filter; - const count = filter!.count || 0; + assertPresent(filter.targetId, 'filter.targetId'); + const count = filter.count || 0; const existenceFilter = new ExistenceFilter(count); - const targetId = filter!.targetId!; + const targetId = filter.targetId; watchChange = new ExistenceFilterChange(targetId, existenceFilter); } else { return fail('Unknown change type ' + JSON.stringify(change)); @@ -865,7 +862,7 @@ export class JsonProtoSerializer { if (proto.update) { assertPresent(proto.update.name, 'name'); - const key = this.fromName(proto.update.name!); + const key = this.fromName(proto.update.name); const value = this.fromFields(proto.update.fields || {}); if (proto.updateMask) { const fieldMask = this.fromDocumentMask(proto.updateMask); @@ -950,7 +947,7 @@ export class JsonProtoSerializer { commitTime !== undefined, 'Received a write result without a commit time' ); - return protos.map(proto => this.fromWriteResult(proto, commitTime!)); + return protos.map(proto => this.fromWriteResult(proto, commitTime)); } else { return []; } diff --git a/packages/firestore/src/remote/stream_bridge.ts b/packages/firestore/src/remote/stream_bridge.ts index 49f9bfd6fc0..28b2ecf6592 100644 --- a/packages/firestore/src/remote/stream_bridge.ts +++ b/packages/firestore/src/remote/stream_bridge.ts @@ -66,7 +66,7 @@ export class StreamBridge implements Stream { this.wrappedOnOpen !== undefined, 'Cannot call onOpen because no callback was set' ); - this.wrappedOnOpen!(); + this.wrappedOnOpen(); } callOnClose(err?: FirestoreError): void { @@ -74,7 +74,7 @@ export class StreamBridge implements Stream { this.wrappedOnClose !== undefined, 'Cannot call onClose because no callback was set' ); - this.wrappedOnClose!(err); + this.wrappedOnClose(err); } callOnMessage(msg: O): void { @@ -82,6 +82,6 @@ export class StreamBridge implements Stream { this.wrappedOnMessage !== undefined, 'Cannot call onMessage because no callback was set' ); - this.wrappedOnMessage!(msg); + this.wrappedOnMessage(msg); } } diff --git a/packages/firestore/src/util/assert.ts b/packages/firestore/src/util/assert.ts index 77561e9f969..4abb39db580 100644 --- a/packages/firestore/src/util/assert.ts +++ b/packages/firestore/src/util/assert.ts @@ -43,7 +43,7 @@ export function fail(failure: string): never { * Fails if the given assertion condition is false, throwing an Error with the * given message if it did. */ -export function assert(assertion: boolean, message: string): void { +export function assert(assertion: boolean, message: string): asserts assertion { if (!assertion) { fail(message); } diff --git a/packages/firestore/test/unit/local/local_store.test.ts b/packages/firestore/test/unit/local/local_store.test.ts index 999a5c2cd2d..8e19580dc14 100644 --- a/packages/firestore/test/unit/local/local_store.test.ts +++ b/packages/firestore/test/unit/local/local_store.test.ts @@ -300,9 +300,9 @@ class LocalStoreTester { this.lastChanges !== null, 'Called toReturnChanged() without prior after()' ); - expect(this.lastChanges!.size).to.equal(docs.length, 'number of changes'); + expect(this.lastChanges.size).to.equal(docs.length, 'number of changes'); for (const doc of docs) { - const returned = this.lastChanges!.get(doc.key); + const returned = this.lastChanges.get(doc.key); expectEqual( doc, returned, @@ -322,12 +322,12 @@ class LocalStoreTester { this.lastChanges !== null, 'Called toReturnRemoved() without prior after()' ); - expect(this.lastChanges!.size).to.equal( + expect(this.lastChanges.size).to.equal( keyStrings.length, 'Number of actual changes mismatched number of expected changes' ); for (const keyString of keyStrings) { - const returned = this.lastChanges!.get(key(keyString)); + const returned = this.lastChanges.get(key(keyString)); expect(returned).to.be.an.instanceof(NoDocument); } this.lastChanges = null; diff --git a/packages/firestore/test/util/helpers.ts b/packages/firestore/test/util/helpers.ts index 026a68f0081..7ac49374986 100644 --- a/packages/firestore/test/util/helpers.ts +++ b/packages/firestore/test/util/helpers.ts @@ -571,7 +571,7 @@ export function documentSet(...args: unknown[]): DocumentSet { } for (const doc of args) { assert(doc instanceof Document, 'Bad argument, expected Document: ' + doc); - docSet = docSet.add(doc as Document); + docSet = docSet.add(doc); } return docSet; }