You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a type mismatch between the QueryDocumentSnapshot exported by firebase/firestore & firebase/compat/app.
We've are hoping to incrementally adopt the modular style/syntax of version 9 of this library.
We have converters that are defined using the types exported from firebase/firestore, but we use these converters with code exported from firebase/compat/app/firebase/compat/firestore.
i.e.
import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';
import ThingyConverter from './converter'; // defined using type from new module
...
const docRef = firebase.firestore().doc('col/1).withConverter(ThingConverter)
Attempting to do so result in a type error.
Type 'firebase.default.firestore.QueryDocumentSnapshot<firebase.default.firestore.DocumentData>' is not assignable to type 'import(".../firebase-converter-type-repro/node_modules/@firebase/firestore/dist/index").QueryDocumentSnapshot<import(".../firebase-converter-type-repro/node_modules/@firebase/firestore/dist/index").DocumentData>'.
Types of property 'exists' are incompatible.
Type 'boolean' is not assignable to type '() => this is QueryDocumentSnapshot<DocumentData>'.ts(2322)
I don't understand why these types don't match, they are exported from the same package.
The types exposed by firestore-compat and firestore are not interchangeable. QueryDocumentSnapshot.exists() is a a function in v9, as we would to use the return type as a type-guard. While you should be able to use the QueryDocumentSnapshot from firestore-compat and firestore in all of our Firestore APIs, you cannot assign them to the same variable as TS will correctly detect the signature mismatch.
Uh oh!
There was an error while loading. Please reload this page.
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
There is a type mismatch between the
QueryDocumentSnapshot
exported byfirebase/firestore
&firebase/compat/app
.We've are hoping to incrementally adopt the modular style/syntax of version 9 of this library.
We have converters that are defined using the types exported from
firebase/firestore
, but we use these converters with code exported fromfirebase/compat/app
/firebase/compat/firestore
.i.e.
Attempting to do so result in a type error.
I don't understand why these types don't match, they are exported from the same package.
Relevant Code:
This is a minimal repro that exhibits the type error
https://github.com/goleary/firebase-converter-type-repro
The text was updated successfully, but these errors were encountered: