@@ -16,8 +16,6 @@ export const noop = () => {}
16
16
17
17
export const isClient = typeof window !== 'undefined'
18
18
19
- // TODO: replace any with unknown or T generics if possible and worth
20
-
21
19
export interface OperationsType {
22
20
set < T extends object = Record < any , unknown > > (
23
21
target : T ,
@@ -52,7 +50,7 @@ export type TODO = any
52
50
* @param obj
53
51
* @param path
54
52
*/
55
- export function walkGet ( obj : Record < string , any > , path : string ) : any {
53
+ export function walkGet ( obj : Record < string , TODO > , path : string ) : TODO {
56
54
return path . split ( '.' ) . reduce ( ( target , key ) => target && target [ key ] , obj )
57
55
}
58
56
@@ -91,24 +89,16 @@ export function walkSet<T extends object = Record<any, unknown>>(
91
89
* Checks if a variable is an object
92
90
* @param o
93
91
*/
94
- export function isObject ( o : any ) : o is Record < any , unknown > {
95
- return o && typeof o === 'object'
96
- }
97
-
98
- /**
99
- * Checks if a variable is a Date
100
- * @param o
101
- */
102
- export function isTimestamp ( o : any ) : o is Timestamp {
103
- return o . toDate
92
+ export function isObject ( o : unknown ) : o is Record < any , unknown > {
93
+ return ! ! o && typeof o === 'object'
104
94
}
105
95
106
96
/**
107
97
* Checks if a variable is a Firestore Document Reference
108
98
* @param o
109
99
*/
110
100
export function isDocumentRef < T = DocumentData > (
111
- o : any
101
+ o : unknown
112
102
) : o is DocumentReference < T > {
113
103
return isObject ( o ) && o . type === 'document'
114
104
}
@@ -118,13 +108,13 @@ export function isDocumentRef<T = DocumentData>(
118
108
* @param o
119
109
*/
120
110
export function isCollectionRef < T = DocumentData > (
121
- o : any
111
+ o : unknown
122
112
) : o is CollectionReference < T > {
123
113
return isObject ( o ) && o . type === 'collection'
124
114
}
125
115
126
116
export function isFirestoreDataReference < T = unknown > (
127
- source : any
117
+ source : unknown
128
118
) : source is CollectionReference < T > | DocumentReference < T > {
129
119
return isDocumentRef ( source ) || isCollectionRef ( source )
130
120
}
@@ -155,12 +145,14 @@ export function getDataSourcePath(
155
145
}
156
146
157
147
export function isDatabaseReference (
158
- source : any
148
+ source : unknown
159
149
) : source is DatabaseReference | DatabaseQuery {
160
150
return isObject ( source ) && 'ref' in source
161
151
}
162
152
163
- export function isStorageReference ( source : any ) : source is StorageReference {
153
+ export function isStorageReference (
154
+ source : unknown
155
+ ) : source is StorageReference {
164
156
return isObject ( source ) && typeof source . bucket === 'string'
165
157
}
166
158
0 commit comments