@@ -6,29 +6,18 @@ import type {
6
6
} from 'firebase/firestore'
7
7
import { App , ComponentPublicInstance , effectScope , toRef } from 'vue'
8
8
import { isVue3 } from 'vue-demi'
9
- import {
10
- bindCollection ,
11
- bindDocument ,
12
- firestoreOptions ,
13
- FirestoreRefOptions ,
14
- _GlobalFirestoreRefOptions ,
15
- } from './subscribe'
9
+ import { FirestoreRefOptions , _GlobalFirestoreRefOptions } from './subscribe'
16
10
import { internalUnbind , _useFirestoreRef } from '.'
17
- import { ResetOption , UnbindWithReset } from '../shared'
18
- import { firebaseApp } from '../../tests/utils'
11
+ import { ResetOption , UnbindWithReset , _FirestoreDataSource } from '../shared'
19
12
import { FirebaseApp } from 'firebase/app'
20
13
import { getGlobalScope } from '../globals'
21
14
import { useFirebaseApp } from '../app'
22
15
23
- export type VueFirestoreObject = Record <
24
- string ,
25
- DocumentReference < unknown > | Query < unknown > | CollectionReference < unknown >
26
- >
16
+ // TODO: this should be an entry point to generate the corresponding .d.ts file that only gets included if the plugin is imported
27
17
18
+ export type VueFirestoreObject = Record < string , _FirestoreDataSource >
28
19
export type FirestoreOption = VueFirestoreObject | ( ( ) => VueFirestoreObject )
29
20
30
- // TODO: this should be an entry point to generate the corresponding .d.ts file that only gets included if the plugin is imported
31
-
32
21
export const firestoreUnbinds = new WeakMap <
33
22
object ,
34
23
Record < string , UnbindWithReset >
@@ -40,7 +29,14 @@ export const firestoreUnbinds = new WeakMap<
40
29
*/
41
30
export interface FirestorePluginOptions
42
31
extends Partial < _GlobalFirestoreRefOptions > {
32
+ /**
33
+ * @deprecated : was largely unused and not very useful. Please open an issue with use cases if you need this.
34
+ */
43
35
bindName ?: string
36
+
37
+ /**
38
+ * @deprecated : was largely unused and not very useful. Please open an issue with use cases if you need this.
39
+ */
44
40
unbindName ?: string
45
41
}
46
42
@@ -90,10 +86,7 @@ export const firestorePlugin = function firestorePlugin(
90
86
GlobalTarget [ bindName ] = function firestoreBind (
91
87
this : ComponentPublicInstance ,
92
88
key : string ,
93
- docOrCollectionRef :
94
- | Query < unknown >
95
- | CollectionReference < unknown >
96
- | DocumentReference < unknown > ,
89
+ docOrCollectionRef : _FirestoreDataSource ,
97
90
userOptions ?: FirestoreRefOptions
98
91
) {
99
92
const options = Object . assign ( { } , globalOptions , userOptions )
@@ -195,20 +188,17 @@ declare module '@vue/runtime-core' {
195
188
* @param reference
196
189
* @param options
197
190
*/
198
- $firestoreBind (
191
+ $firestoreBind < T = DocumentData > (
199
192
name : string ,
200
- // TODO: create proper overloads with generics like in the composition API
201
- reference : Query < unknown > | CollectionReference < unknown > ,
193
+ reference : Query < T > | CollectionReference < T > ,
202
194
options ?: FirestoreRefOptions
203
- // TODO: match the promise with the type of internalBind
204
- ) : Promise < DocumentData [ ] >
195
+ ) : Promise < T [ ] >
205
196
206
- $firestoreBind (
197
+ $firestoreBind < T = DocumentData > (
207
198
name : string ,
208
- // TODO: create proper overloads with generics like in the composition API
209
- reference : DocumentReference < unknown > ,
199
+ reference : DocumentReference < T > ,
210
200
options ?: FirestoreRefOptions
211
- ) : Promise < DocumentData >
201
+ ) : Promise < T >
212
202
213
203
/**
214
204
* Unbinds a bound reference
0 commit comments