Description
Version info
Angular:
16.1.3
Firebase:
9.23.0
AngularFire:
7.6.1
How to reproduce these conditions
Steps to set up and reproduce
Just download the .zip with the code of version 7.6.1 and open the file `src/compat/firestore/interfaces.ts.
You'll see that the released code in this file doesn't correspond with what's actually in the master
branch.
From the release:
import { Subscriber } from 'rxjs';
import firebase from 'firebase/compat/app';
export type Settings = firebase.firestore.Settings;
export type CollectionReference<T = DocumentData> = firebase.firestore.CollectionReference<T>;
export type DocumentReference<T = DocumentData> = firebase.firestore.DocumentReference<T>;
export type PersistenceSettings = firebase.firestore.PersistenceSettings;
export type DocumentChangeType = firebase.firestore.DocumentChangeType;
export type SnapshotOptions = firebase.firestore.SnapshotOptions;
export type FieldPath = firebase.firestore.FieldPath;
export type Query<T = DocumentData> = firebase.firestore.Query<T>;
export type SetOptions = firebase.firestore.SetOptions;
export type DocumentData = firebase.firestore.DocumentData;
export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
readonly exists: true;
data(options?: SnapshotOptions): T;
}
export interface DocumentSnapshotDoesNotExist extends firebase.firestore.DocumentSnapshot {
readonly exists: false;
data(options?: SnapshotOptions): undefined;
get(fieldPath: string | FieldPath, options?: SnapshotOptions): undefined;
}
export type DocumentSnapshot<T> = DocumentSnapshotExists<T> | DocumentSnapshotDoesNotExist;
export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {
data(options?: SnapshotOptions): T;
}
export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {
readonly docs: QueryDocumentSnapshot<T>[];
}
export interface DocumentChange<T> extends firebase.firestore.DocumentChange {
readonly doc: QueryDocumentSnapshot<T>;
}
You can see that the interfaces DocumentSnapshotExists
, QueryDocumentSnapshot
, QuerySnapshot
, and DocumentChange
are incorrectly extending the interfaces from firebase.firestore
.
However, that's not the code that can be seen in the master
branch:
angularfire/src/compat/firestore/interfaces.ts
Lines 1 to 40 in 34e89a4
NOTE: I have cloned the repo and run a yarn build
to see the result, and I've confirmed that that command is generating the right code. I don't know what is on the 7.6.1 release, but it's not the direct result from cloning master
and running a yarn build
command.
Debug output
Errors in the console
I get the following errors while trying to compile the project:
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
~
This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
~
This type parameter might need an `extends firebase.firestore.DocumentData | undefined` constraint.
Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:23:18 - error TS2430: Interface 'QueryDocumentSnapshot<T>' incorrectly extends interface 'QueryDocumentSnapshot<DocumentData>'.
The types returned by 'data(...)' are incompatible between these types.
Type 'T' is not assignable to type 'DocumentData'.
23 export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {
~~~~~~~~~~~~~~~~~~~~~
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:23:40
23 export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {
~
This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:26:18 - error TS2430: Interface 'QuerySnapshot<T>' incorrectly extends interface 'QuerySnapshot<DocumentData>'.
Types of property 'docs' are incompatible.
Type 'QueryDocumentSnapshot<T>[]' is not assignable to type 'QueryDocumentSnapshot<DocumentData>[]'.
Type 'QueryDocumentSnapshot<T>' is not assignable to type 'QueryDocumentSnapshot<DocumentData>'.
The types returned by 'data(...)' are incompatible between these types.
Type 'T' is not assignable to type 'DocumentData'.
26 export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {
~~~~~~~~~~~~~
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:26:32
26 export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {
~
This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:29:18 - error TS2430: Interface 'DocumentChange<T>' incorrectly extends interface 'DocumentChange<DocumentData>'.
The types returned by 'doc.data(...)' are incompatible between these types.
Type 'T' is not assignable to type 'DocumentData'.
29 export interface DocumentChange<T> extends firebase.firestore.DocumentChange {
~~~~~~~~~~~~~~
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:29:33
29 export interface DocumentChange<T> extends firebase.firestore.DocumentChange {
~
This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
Expected behavior
The project should compile.
Actual behavior
The project doesn't compile.