New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(deprecation)!: remove legacy support for array arguments #625
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b6d574f
Remove legacy support for array arguments
schmidt-sebastian 784c0fd
Update JSDoc
schmidt-sebastian 84b5ad3
Merge branch 'master' into mrschmidt-simplifygetall
JustinBeckwith 93e51a3
Fix conformance test
schmidt-sebastian 2d95bf3
Merge branch 'mrschmidt-simplifygetall' of https://github.com/googlea…
schmidt-sebastian 667d715
Merge branch 'master' into mrschmidt-simplifygetall
schmidt-sebastian File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,9 +163,8 @@ export class Transaction { | |
* followed by any additional `DocumentReference` documents. If used, the | ||
* optional `ReadOptions` must be the last argument. | ||
* | ||
* @param {Array.<DocumentReference|ReadOptions>} documentRefsOrReadOptions | ||
* The `DocumentReferences` to receive, followed by an optional field | ||
* mask. | ||
* @param {...DocumentReference|ReadOptions} documentRefsOrReadOptions The | ||
* `DocumentReferences` to receive, followed by an optional field mask. | ||
* @returns {Promise<Array.<DocumentSnapshot>>} A Promise that | ||
* contains an array with the resulting document snapshots. | ||
* | ||
|
@@ -433,30 +432,23 @@ export function parseGetAllArguments( | |
let documents: DocumentReference[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't comment on unchanged code, but does the getAll() parameter definition need to be updated somehow?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I fixed the JSDoc as well. |
||
let readOptions: ReadOptions | undefined = undefined; | ||
|
||
// 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 (usesDeprecatedArgumentStyle) { | ||
documents = documentRefsOrReadOptions[0] as DocumentReference[]; | ||
readOptions = documentRefsOrReadOptions[1] as ReadOptions; | ||
if (Array.isArray(documentRefsOrReadOptions[0])) { | ||
throw new Error( | ||
'getAll() no longer accepts an array as its first argument. ' + | ||
'Please unpack your array and call getAll() with individual arguments.' | ||
); | ||
} | ||
|
||
if ( | ||
documentRefsOrReadOptions.length > 0 && | ||
isPlainObject( | ||
documentRefsOrReadOptions[documentRefsOrReadOptions.length - 1] | ||
) | ||
) { | ||
readOptions = documentRefsOrReadOptions.pop() as ReadOptions; | ||
documents = documentRefsOrReadOptions as DocumentReference[]; | ||
} else { | ||
if ( | ||
documentRefsOrReadOptions.length > 0 && | ||
isPlainObject( | ||
documentRefsOrReadOptions[documentRefsOrReadOptions.length - 1] | ||
) | ||
) { | ||
readOptions = documentRefsOrReadOptions.pop() as ReadOptions; | ||
documents = documentRefsOrReadOptions as DocumentReference[]; | ||
} else { | ||
documents = documentRefsOrReadOptions as DocumentReference[]; | ||
} | ||
documents = documentRefsOrReadOptions as DocumentReference[]; | ||
} | ||
|
||
for (let i = 0; i < documents.length; ++i) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
string[]
from the param type definition above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also removed "undocumented" from the PR description...