1
votes

I'm trying to declare a variable in my service for an AngularFirestoreDocument ref. When I do so I get this TypeScript error:

Generic type 'AngularFirestoreDocument' requires 2 type argument(s)

I've seen it done this way in multiple code examples and can't figure out why I'm getting this error. It does compile okay.

Versions:

  • angular: 6.0.2
  • angularfire2: 5.0.0-rc.10
  • firebase: 5.0.4

Here is a snippet of the code:

import { AngularFirestore, AngularFirestoreDocument } from 'angularfire2/firestore';

@Injectable()
export class GiftListService {
  giftListRef: AngularFirestoreDocument<GiftList>;
1
are Imports ok? Import { AngularFirestoreDocument} - Diego Venâncio
@DiegoVenâncio Yes imports look correct. I edited my post to include imports. - jsparks
In app.module do you put all correct imports[ AngularFireModule.initializeApp(environment.firebase), AngularFirestoreModule,]: ? - Diego Venâncio

1 Answers

0
votes

Try testing it with giftListRef: AngularFirestoreDocument<any> Below is the current definition of AngularFirestoreDocument so if yours is different then you need to do a fresh npm install. The culprit is probably typescript version.

(alias) class AngularFirestoreDocument<T = { [field: string]: any; }>