unfortunately this is not flexible enough to handle field value as field value output is different from input
especially server timestamp, also apply to number and array where they can accept field value
we still need better wrapper
const converter = {
toFirestore: (data: { createdAt: Firestore.FieldValue }) => data, // server time stamp
fromFirestore: (snap: FirebaseFirestore.QueryDocumentSnapshot) =>
snap.data() as {
createdAt: Firestore.Timestamp // timestamp object
},
}
firestore().collection('users').withConverter(converter) // type error