@@ -6,29 +6,18 @@ import type {
66} from 'firebase/firestore'
77import { App , ComponentPublicInstance , effectScope , toRef } from 'vue'
88import { 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'
1610import { internalUnbind , _useFirestoreRef } from '.'
17- import { ResetOption , UnbindWithReset } from '../shared'
18- import { firebaseApp } from '../../tests/utils'
11+ import { ResetOption , UnbindWithReset , _FirestoreDataSource } from '../shared'
1912import { FirebaseApp } from 'firebase/app'
2013import { getGlobalScope } from '../globals'
2114import { useFirebaseApp } from '../app'
2215
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
2717
18+ export type VueFirestoreObject = Record < string , _FirestoreDataSource >
2819export type FirestoreOption = VueFirestoreObject | ( ( ) => VueFirestoreObject )
2920
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-
3221export const firestoreUnbinds = new WeakMap <
3322 object ,
3423 Record < string , UnbindWithReset >
@@ -40,7 +29,14 @@ export const firestoreUnbinds = new WeakMap<
4029 */
4130export interface FirestorePluginOptions
4231 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+ */
4335 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+ */
4440 unbindName ?: string
4541}
4642
@@ -90,10 +86,7 @@ export const firestorePlugin = function firestorePlugin(
9086 GlobalTarget [ bindName ] = function firestoreBind (
9187 this : ComponentPublicInstance ,
9288 key : string ,
93- docOrCollectionRef :
94- | Query < unknown >
95- | CollectionReference < unknown >
96- | DocumentReference < unknown > ,
89+ docOrCollectionRef : _FirestoreDataSource ,
9790 userOptions ?: FirestoreRefOptions
9891 ) {
9992 const options = Object . assign ( { } , globalOptions , userOptions )
@@ -195,20 +188,17 @@ declare module '@vue/runtime-core' {
195188 * @param reference
196189 * @param options
197190 */
198- $firestoreBind (
191+ $firestoreBind < T = DocumentData > (
199192 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 > ,
202194 options ?: FirestoreRefOptions
203- // TODO: match the promise with the type of internalBind
204- ) : Promise < DocumentData [ ] >
195+ ) : Promise < T [ ] >
205196
206- $firestoreBind (
197+ $firestoreBind < T = DocumentData > (
207198 name : string ,
208- // TODO: create proper overloads with generics like in the composition API
209- reference : DocumentReference < unknown > ,
199+ reference : DocumentReference < T > ,
210200 options ?: FirestoreRefOptions
211- ) : Promise < DocumentData >
201+ ) : Promise < T >
212202
213203 /**
214204 * Unbinds a bound reference
0 commit comments