From 738ce7efdf381574234728376b33a13517d4bdd8 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Sat, 10 Nov 2018 15:08:19 -0800 Subject: [PATCH] Review feedback --- dev/src/transaction.ts | 2 +- dev/src/util.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 80d0cc4a8..a9a154c06 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -118,7 +118,7 @@ export class Transaction { if (refOrQuery instanceof DocumentReference) { return this._firestore - .getAll_([refOrQuery], null, this._requestTag, this._transactionId) + .getAll_([refOrQuery], /* fieldMask= */ null, this._requestTag, this._transactionId) .then(res => { return Promise.resolve(res[0]); }); diff --git a/dev/src/util.ts b/dev/src/util.ts index 755c5fc6b..f2108a485 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -65,9 +65,17 @@ export function parseGetAllArguments( let documents: DocumentReference[]; let readOptions: ReadOptions|undefined = undefined; - const usesVarags = !Array.isArray(documentRefsOrReadOptions[0]); + // In the original release of the SDK, getAll() was documented to accept + // either a varargs list of DocumentReferences or a single array of + // DocumentReferences. To support this usage in the TypeScript client, we have + // to manually verify the arguments to determine which input the user + // provided. + const usesDeprecatedArgumentStyle = Array.isArray(documentRefsOrReadOptions[0]); - if (usesVarags) { + if (usesDeprecatedArgumentStyle) { + documents = documentRefsOrReadOptions[0] as DocumentReference[]; + readOptions = documentRefsOrReadOptions[1] as ReadOptions; + } else { if (documentRefsOrReadOptions.length > 0 && isPlainObject( documentRefsOrReadOptions[documentRefsOrReadOptions.length - 1])) { @@ -76,11 +84,6 @@ export function parseGetAllArguments( } else { documents = documentRefsOrReadOptions as DocumentReference[]; } - } else { - // Support an array of document references as the first argument for - // backwards compatibility. - documents = documentRefsOrReadOptions[0] as DocumentReference[]; - readOptions = documentRefsOrReadOptions[1] as ReadOptions; } for (let i = 0; i < documents.length; ++i) {