Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda