@@ -62,6 +62,7 @@ import {
62
62
findFilterOperator ,
63
63
getFirstOrderByField ,
64
64
getInequalityFilterField ,
65
+ hasLimitToLast ,
65
66
isCollectionGroupQuery ,
66
67
LimitType ,
67
68
newQueryComparator ,
@@ -76,8 +77,7 @@ import {
76
77
queryWithAddedOrderBy ,
77
78
queryWithEndAt ,
78
79
queryWithLimit ,
79
- queryWithStartAt ,
80
- hasLimitToLast
80
+ queryWithStartAt
81
81
} from '../core/query' ;
82
82
import { Transaction as InternalTransaction } from '../core/transaction' ;
83
83
import { ChangeType , ViewSnapshot } from '../core/view_snapshot' ;
@@ -92,11 +92,11 @@ import { debugAssert, fail } from '../util/assert';
92
92
import { AsyncQueue } from '../util/async_queue' ;
93
93
import { Code , FirestoreError } from '../util/error' ;
94
94
import {
95
- invalidClassError ,
96
- validatePositiveNumber ,
97
- valueDescription ,
95
+ cast ,
98
96
validateIsNotUsedTogether ,
99
- validateNonEmptyString
97
+ validateNonEmptyString ,
98
+ validatePositiveNumber ,
99
+ valueDescription
100
100
} from '../util/input_validation' ;
101
101
import { getLogLevel , logError , LogLevel , setLogLevel } from '../util/log' ;
102
102
import { AutoId } from '../util/misc' ;
@@ -1022,7 +1022,7 @@ export class DocumentReference<T = DocumentData>
1022
1022
1023
1023
isEqual ( other : PublicDocumentReference < T > ) : boolean {
1024
1024
if ( ! ( other instanceof DocumentReference ) ) {
1025
- throw invalidClassError ( 'isEqual' , 'DocumentReference' , 1 , other ) ;
1025
+ return false ;
1026
1026
}
1027
1027
return (
1028
1028
this . firestore === other . firestore &&
@@ -1346,7 +1346,7 @@ export class DocumentSnapshot<T = DocumentData>
1346
1346
1347
1347
isEqual ( other : PublicDocumentSnapshot < T > ) : boolean {
1348
1348
if ( ! ( other instanceof DocumentSnapshot ) ) {
1349
- throw invalidClassError ( 'isEqual' , 'DocumentSnapshot' , 1 , other ) ;
1349
+ return false ;
1350
1350
}
1351
1351
return (
1352
1352
this . _firestore === other . _firestore &&
@@ -1924,7 +1924,7 @@ export class Query<T = DocumentData> implements PublicQuery<T> {
1924
1924
1925
1925
isEqual ( other : PublicQuery < T > ) : boolean {
1926
1926
if ( ! ( other instanceof Query ) ) {
1927
- throw invalidClassError ( 'isEqual' , 'Query' , 1 , other ) ;
1927
+ return false ;
1928
1928
}
1929
1929
return (
1930
1930
this . firestore === other . firestore &&
@@ -2126,7 +2126,7 @@ export class QuerySnapshot<T = DocumentData> implements PublicQuerySnapshot<T> {
2126
2126
/** Check the equality. The call can be very expensive. */
2127
2127
isEqual ( other : PublicQuerySnapshot < T > ) : boolean {
2128
2128
if ( ! ( other instanceof QuerySnapshot ) ) {
2129
- throw invalidClassError ( 'isEqual' , 'QuerySnapshot' , 1 , other ) ;
2129
+ return false ;
2130
2130
}
2131
2131
2132
2132
return (
@@ -2199,6 +2199,7 @@ export class CollectionReference<T = DocumentData>
2199
2199
if ( arguments . length === 0 ) {
2200
2200
pathString = AutoId . newId ( ) ;
2201
2201
}
2202
+ validateNonEmptyString ( 'CollectionReference.doc' , 'path' , pathString ) ;
2202
2203
const path = ResourcePath . fromString ( pathString ! ) ;
2203
2204
return DocumentReference . forPath < T > (
2204
2205
this . _query . path . child ( path ) ,
@@ -2264,15 +2265,14 @@ function validateReference<T>(
2264
2265
documentRef : PublicDocumentReference < T > ,
2265
2266
firestore : Firestore
2266
2267
) : _DocumentKeyReference < T > {
2267
- if ( ! ( documentRef instanceof _DocumentKeyReference ) ) {
2268
- throw invalidClassError ( methodName , 'DocumentReference' , 1 , documentRef ) ;
2269
- } else if ( documentRef . firestore !== firestore ) {
2268
+ const reference = cast < DocumentReference < T > > ( documentRef , DocumentReference ) ;
2269
+ if ( reference . firestore !== firestore ) {
2270
2270
throw new FirestoreError (
2271
2271
Code . INVALID_ARGUMENT ,
2272
2272
'Provided document reference is from a different Firestore instance.'
2273
2273
) ;
2274
2274
} else {
2275
- return documentRef ;
2275
+ return reference ;
2276
2276
}
2277
2277
}
2278
2278
0 commit comments