angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

collection function has no generic type

Open zadokdaniel opened this issue 4 years ago • 2 comments

Version info

Angular: 12.2.0 Firebase: 9.4.0 AngularFire: 7.2.0

How to reproduce these conditions

import { collection, } from '@angular/fire/firestore';

Expected behavior

collection suppose to receive generic type of collection documents interface. as stated in docs

import { collection } from '@angular/fire/firestore'; collection<T>(firestore, 'foo') // CollectionReference<T>

Actual behavior

generic type is not configured, hence causing a problem on passing to update and doc functions with the generic type of the interface set Code_Y7nW5tuIqt chrome_9x67l0gpG5

.

zadokdaniel avatar Nov 22 '21 17:11 zadokdaniel

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Nov 22 '21 17:11 google-oss-bot

I was also surprised, since the other functions are generic. As a workaround u can type it for now manually:

protected readonly resumesCollection = collection( this.firestore, 'resumes' ) as CollectionReference<Resume>;

and then those calls will infer the type

getDocs(query(this.resumesCollection, where('user', '==', user?.uid)))

RobbyRabbitman avatar May 19 '22 17:05 RobbyRabbitman