Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
firestore.Timestamp import is undefined in firebase-admin@11

In firebase-admin@10 I used to retrieve the document data using this approach:

const userRef = await firestore()
  .collection('users')
  .withConverter(UserConverter)
  .doc(userId)
  .get();

const userData = userRef.data();

But recently I upgraded to firebase-admin@11 and now calling userRef.data() throws an error:

TypeError: Right-hand side of 'instanceof' is not an object`.

I tried downgrading to version 10 - it solved the issue. But I'd like to know what is the right solution in the latest version - I couldn't find it.

Upd. I've found the source of the problem: in my UserConverter I have such a check:

import { firestore } from "firebase-admin";
import { DateTime } from "luxon";
import { UserEntity } from "../entities";

export class UserEntityConverter implements firestore.FirestoreDataConverter<UserEntity> {
  toFirestore(modelObject: UserEntity): firestore.DocumentData;
  toFirestore(modelObject: Partial<UserEntity>, options: firestore.SetOptions): firestore.DocumentData;
  toFirestore(modelObject: UserEntity | Partial<UserEntity>, options?: firestore.SetOptions): firestore.DocumentData {
    return {
      balance: modelObject.balance,
      lastLoggedAt: modelObject.lastLoggedAt?.toJSDate() || null,
    };
  }

  fromFirestore(snapshot: firestore.QueryDocumentSnapshot<firestore.DocumentData>): UserEntity {
  const data = snapshot.data();

  userEntity.balance = snapshot.balance;

  const lastLoggedAtData = data.lastLoggedAt;
  // this is where it breaks now: `firestore.Timestamp === undefined`
  if (lastLoggedAtData && lastLoggedAtData instanceof firestore.Timestamp) {
    userEntity.collectedRewardAt = DateTime.fromMillis(collectedRewardAtData.toMillis());
  }
}

The source of the problem is firestore.Timestamp - it's undefined now for some reason (though it's still present in the typings).

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!