-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Issue
After upgrading to @angular/[email protected], TypeScript compilation fails when calling .toDate() on Timestamp fields from Firestore documents.
Error
TS2339: Property 'toDate' does not exist on type 'FieldValue | WithFieldValue<Timestamp>'.
Property 'toDate' does not exist on type 'FieldValue'.
Reproduction
import { doc, docData, Timestamp } from '@angular/fire/firestore';
interface Member {
createdAt: Timestamp;
}
const member$ = docData(doc(firestore, 'members/123') as DocumentReference<Member>);
member$.subscribe((member) => {
// ERROR: Property 'toDate' does not exist
const date = member?.createdAt.toDate();
});Environment
- @angular/fire: 21.0.0-rc.0
- @angular/core: 21.0.1
- firebase: 12.6.0 (from 11.8.0)
- TypeScript: 5.9.3
Analysis
Timestamp fields are being typed as FieldValue | WithFieldValue<Timestamp> instead of just Timestamp. The WithFieldValue type (meant for writes) is incorrectly being applied to read operations, causing TypeScript to think the field could be FieldValue, which doesn't have .toDate().
This appears to be a regression from the Firebase SDK v11→v12 upgrade in this RC.
sorcamarian
Metadata
Metadata
Assignees
Labels
No labels