Issue
When I'm writing the following snippet with the TS compiler option 'strict' enabled, I get a compiler error:
import * as firebase from "firebase/app";
import DocumentReference = firebase.firestore.DocumentReference;
...
this.db.collection('users').doc('admin').ref.get()
.then(snap => {
const ref: DocumentReference = snap.ref; // TS2322:Type 'DocumentReference' is not assignable to type 'firebase.firestore.DocumentReference'.
})
How can I fix this?
(It's a snippet from an Angular project using AngularFire2)
Solution
Your import DocumentReference = firebase.firestore.DocumentReference; is wrong.
Try this way:
import { DocumentReference } from '@firebase/firestore-types';
Answered By - Julius Dzidzevičius
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.