@@ -7,7 +7,6 @@ import type {
77 Firestore ,
88} from "firebase/firestore" ;
99
10-
1110interface DocStore < T > {
1211 subscribe : ( cb : ( value : T | null ) => void ) => void | ( ( ) => void ) ;
1312 ref : DocumentReference < T > | null ;
@@ -25,7 +24,6 @@ export function docStore<T = any>(
2524 ref : string | DocumentReference < T > ,
2625 startWith ?: T
2726) : DocStore < T > {
28-
2927 let unsubscribe : ( ) => void ;
3028
3129 // Fallback for SSR
@@ -51,7 +49,10 @@ export function docStore<T = any>(
5149 } ;
5250 }
5351
54- const docRef = typeof ref === 'string' ? doc ( firestore , ref ) as DocumentReference < T > : ref ;
52+ const docRef =
53+ typeof ref === "string"
54+ ? ( doc ( firestore , ref ) as DocumentReference < T > )
55+ : ref ;
5556
5657 const { subscribe } = writable < T | null > ( startWith , ( set ) => {
5758 unsubscribe = onSnapshot ( docRef , ( snapshot ) => {
@@ -70,7 +71,7 @@ export function docStore<T = any>(
7071
7172interface CollectionStore < T > {
7273 subscribe : ( cb : ( value : T | [ ] ) => void ) => void | ( ( ) => void ) ;
73- ref : CollectionReference | Query | null ;
74+ ref : CollectionReference < T > | Query < T > | null ;
7475}
7576
7677/**
@@ -81,10 +82,9 @@ interface CollectionStore<T> {
8182 */
8283export function collectionStore < T > (
8384 firestore : Firestore ,
84- ref : string | Query | CollectionReference ,
85+ ref : string | Query < T > | CollectionReference < T > ,
8586 startWith : T [ ] = [ ]
8687) : CollectionStore < T [ ] > {
87-
8888 let unsubscribe : ( ) => void ;
8989
9090 // Fallback for SSR
@@ -126,4 +126,3 @@ export function collectionStore<T>(
126126 ref : colRef ,
127127 } ;
128128}
129-
0 commit comments