I want to use firebase Timestamp type in a type declaration for firestore document field, but cannot figure out where I can import. Does anybody know?
My code.
import * as functions from "firebase-functions";
const admin = require('firebase-admin');
interface MyDocument {
timestamp1: admin.firestore.Timestamp,
timestamp2: functions.firestore.Timestamp,
}
Error in timestamp1: Cannot find namespace 'admin'.ts(2503)
Error in timestamp2: Namespace '"/path/to/project/functions/node_modules/firebase-functions/lib/providers/firestore"' has no exported member 'Timestamp'.
package.json
"dependencies": {
...
"firebase-admin": "^9.5.0",
"firebase-functions": "^3.13.1",
...
}
Here's the shorthand notation:
import * as admin from 'firebase-admin';
import Timestamp = admin.firestore.Timestamp;
This works for me in my Typescript project:
import * as admin from "firebase-admin";
let t : admin.firestore.Timestamp = //....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With