Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda