Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Typings: Cannot destructure array anymore when calling getAll #501

@ushu

Description

@ushu

Since PR #443 has been merged, the signature for Firestore.getAll() has changed from

getAll(...documents: DocumentReference[]): Promise<DocumentSnapshot[]>

to

getAll(documentRef: DocumentReference, ...moreDocumentRefsOrReadOptions: Array<DocumentReference|ReadOptions>): Promise<DocumentSnapshot[]>

with this change, we cannot use array destructuring anymore to "prepare" the refs to fetch in advance.

For example, I used to do the following:

// step 1 - select the documents to fetch
const userIDs = ... 
const usersRef = admin.firestore().collection("users")
const userRefs: DocumentReference[] = userIDs.map(id => usersRef.doc(id))

// step 2 - Grab-them-all
const snaps = await admin.firestore().getAll(...userRefs)

this won't work anymore (I tried to update TS but it did not fix it), the only workaround is to do something like:

const snaps = await admin.firestore().getAll(
  // extract the first item
  userRefs[0],
  // and then process the remaining elements
  ...(userRefs.slice(1))
)

Environment details

  • OS: Mojave
  • Node.js version: 10.12.0 (TS 3.2.2)
  • npm version: 6.4.1
  • @google-cloud/firestore version: 0.19.0

Steps to reproduce

  1. Create a project with Typescript support
  2. Type the code above (with .getAll(...userRefs)) → it won't compile

Edit: added #502 to restore previously-working behavior

Regards

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: firestoreIssues related to the googleapis/nodejs-firestore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions