Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I implement firebase's Timestamp as a valid type?

ts/ io-ts and am trying to implement Firebase.Timestamp as a valid type. But I keep getting errors. I can create a normal copy of the time stamp:

copyTimeStamp = {
  seconds : t.number,
  nanoseconds : t.number
}

but if I push that onto firebase using the custom encoded type from io-ts, it isn't stored as Timestamp property rather its just a plain map..

like image 809
Darren Zou Avatar asked Oct 30 '25 10:10

Darren Zou


1 Answers

You need to import FirebaseFirestoreTypes from @react-native-firebase/firestore.

Here it is:

import {FirebaseFirestoreTypes} from '@react-native-firebase/firestore';

...

type StateTypes = {
  created_at: FirebaseFirestoreTypes.Timestamp | null;
  updated_at: FirebaseFirestoreTypes.Timestamp | null;
}
like image 118
Mohammad Goldast Avatar answered Nov 01 '25 01:11

Mohammad Goldast



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!