-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
The input type is different to the output type for a date field, however the types in functions etc do not reflect this.
E.g.
type Profile = {
createdAt: Date
}
const { add, data } = useCollection<Profile>('profiles')
add({
// works and correctly stored as a timestamp in Firestore
createdAt: new Date()
})
console.log(data[0].createdAt instance Date) // false
// actually an instance of FirestoreTimestamp
Since the type used is the one passed as a the generic Profile
, the type of createdAt
in data is wrong.
There is also one exception to this rule: if the cache is being used after add
. In that case, there will be two potential types being used... since the cached items that are created via add
use the Date types, whereas the cached items from firebase have the FirestoreTimestamp
type.
This type mismatch also means that sorting does not work correctly.
Metadata
Metadata
Assignees
Labels
No labels