-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hey there!
I've got a collection that looks like this:
type EventCollection = RxCollection<
EventRecordType,
Record<string, never>,
EventCollectionStaticMethods
>;It has some static methods, but if I call useRxCollection(), there's no good way of TypeScript knowing that. The hook only accepts a single generic which is for the document type (i.e. RxCollection<T>), so I can't provide the types for my static methods.
I think it would make more sense if the generic was for the collection itself, rather than the document type, e.g.:
const events = useRxCollection<EventCollection>("events")I realize that's a breaking change, though, so perhaps it would be enough for the function to accept all three generic types? That way, I could at least do this:
declare function useRxCollection<A, B, C>(
name: string,
): RxCollection<A, B, C> | null;
...
const events: EventCollection = useRxCollection("events")Right now, that line of code fails because the second and third generics aren't being passed through.
I'm happy to open a PR if you want, though I think the change would be very quick.
Thanks!