Skip to content

Firestore - typescript has no access to snapshot._document.createTime.timestamp #7544

@davidbielik

Description

@davidbielik

Operating System

any

Browser Version

any

Firebase SDK Version

10.1.0

Firebase SDK Product:

Firestore

Describe your project's tooling

Using typescript:

import {
  CollectionReference,
  DocumentData,
  collection,
  getFirestore,
} from 'firebase/firestore';

const firestore = getFirestore({...});

export const getCollectionRef = <T = DocumentData>(collectionName: string) => {
  return collection(firestore, collectionName) as CollectionReference<T>;
};

Describe the problem

Typescript definitions do not provide a way to access the snapshot._document.createTime property.

Steps and code to reproduce issue

getDocs(collection(firestore, 'users') as CollectionReference<{foo: string}>).then(snapshots => {
  // @ts-expect-error missing typescript definition
  snapshots.docs[0]._document.createTime;
})
image

but the _document is defined:

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions